eseunghwan / python_shell.dart

Python Environment Manager and Executor for dart and flutter
MIT License
3 stars 3 forks source link

The system cannot find the file specified #7

Open baramofme opened 1 year ago

baramofme commented 1 year ago

There is no python.exe when running code with Instance. Because, not created env. Because module not found. ( -m pip not working) Because Path is not set.

flutter: Initializing shell...
flutter: Check default python binary files...
flutter: Python check finished.
flutter: Default settings for virtualenv...
flutter: Virtualenv settings finished.
flutter: Creating default env...
flutter: Creating shell instance [default]...
flutter: Creating virtualenv...
flutter: Virtualenv created.
flutter: Default env created.
flutter: Shell initialized.
flutter: Creating shell instance [default]...
flutter: Installing requirements...
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ProcessException: 지정된 파일을 찾을 수 없습니다.

  Command: C:\Users\UserName\.python_shell.dart\instances\default\env\Scripts\python.exe -m pip install -r C:\Users\UserName\.python_shell.dart\instances\default\temp\requirements.txt
#0      _ProcessImpl._runAndWait (dart:io-patch/process_patch.dart:487:7)
#1      _runNonInteractiveProcessSync (dart:io-patch/process_patch.dart:632:18)
#2      Process.runSync (dart:io-patch/process_patch.dart:68:12)
#3      ShellInstance.installRequires (package:python_shell/src/shell/instance.dart:26:17)
#4      _DesktopAutomationPageState._runPython (package:automation/screens/automation/desktop_automation.dart:38:14)
<asynchronous suspension>

Temp Resolve

You should tell people who use your app, to install python 3.9 globally. or they got stuck.

  1. install python 3.9 from the Microsoft store.
    • you can now run python and python -m [moduleName]
  2. install virtualenv module and make new virtualenv
    PS C:\Users\UserName\.python_shell.dart> python -m pip install virtualenv --upgrade
    PS C:\Users\UserName\.python_shell.dart> python -m virtualenv ./instances/[envNameYouUsedInScript]/env
  3. Now works fine
    var shell = PythonShell(PythonShellConfig());
    await shell.initialize();

    var instance = ShellManager.getInstance("default");
    instance.installRequires([ "PySide6" ]);
    await instance.runString("""
import os, PySide6

print("in python: ", os.getcwd())
print("in python: ", PySide6)
""", echo: true);

    print("finished");