Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PythonFfiException: Failed to cache Python runtime for version 3.11.3 on windows #16

Open
bmsrangel opened this issue Sep 5, 2023 · 4 comments
Labels
blocked This issue will be addressed later. bug Something isn't working

Comments

@bmsrangel
Copy link

When trying to run the command dart run dartpip install on Windows 11, an exception was thrown:

PS python_ffi_poc> dart run dartpip install
supportDir: C:\Users\[...]\AppData\Local\Temp
Unhandled exception:
PythonFfiException: Failed to cache Python runtime for version 3.11.3 on windows
#0      PythonFfiCPythonDart._ensurePythonRuntime (package:python_ffi_cpython_dart/src/python_ffi_cpython_dart_base.dart:144:7)
<asynchronous suspension>
#1      PythonFfiCPythonDart.openDylib (package:python_ffi_cpython_dart/src/python_ffi_cpython_dart_base.dart:115:7)
<asynchronous suspension>
#2      PythonFfiCPythonMixin.initialize (package:python_ffi_cpython_dart/src/python_ffi_cpython_dart_base.dart:416:7)
<asynchronous suspension>
#3      solve (package:dartpip_solver/src/dartpip_solver_base.dart:49:3)
<asynchronous suspension>
#4      InstallCommand._collectAllDependencies (package:dartpip/commands/install.dart:113:58)
<asynchronous suspension>
#5      InstallCommand._downloadAllDependencies (package:dartpip/commands/install.dart:138:9)
<asynchronous suspension>
#6      InstallCommand.run (package:dartpip/commands/install.dart:190:34)
<asynchronous suspension>
#7      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#8      main (file:///C:/Users/[...]/AppData/Local/Pub/Cache/git/dart_python_ffi-8c63ce86bc25d9bbeed222389088f30583d67db9/packages/dartpip/bin/dartpip.dart:14:3)
<asynchronous suspension>

Note: I do have Python 3.11.5 installed on the PC and I'm using the latest GitHub updates of the repo (main branch).

PS C:\Users\[...]\Programming\python_ffi_poc> python --version
Python 3.11.5

So, I decided to try to use the download command first, and then the bundle command:

PS C:\Users\[...]\Programming\python_ffi_poc> dart run dartpip download openpyxl
Cache directory: null/.dartpip/cache/pypi
Downloading Python module 'openpyxl'...
Downloading https://files.pythonhosted.org/packages/42/e8/af028681d493814ca9c2ff8106fc62a4a32e4e0ae14602c2a98fc7b741c8/openpyxl-3.1.2.tar.gz...
Extracting null/.dartpip/cache/pypi/openpyxl-3.1.2.tar.gz...
PS C:\Users\[...]\Programming\python_ffi_poc> dart run dartpip bundle -r . -m python-modules
Bundling Python module 'basic_operations'...
Bundling Python module 'excel_test'...

From that, I noticed that the cache folder (null/.dartpip...) was created in the root of the project and the openpyxl files were extracted there. However, its dependency (et-xmlfile) was not downloaded. Also, none of those files were included under python-modules folder.
image

Flutter Doctor:

PS C:\Users\[...]\Programming\python_ffi_poc> flutter doctor -v
[✓] Flutter (Channel stable, 3.13.2, on Microsoft Windows [Version 10.0.22621.2134], locale pt-BR)
    • Flutter version 3.13.2 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (12 days ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✗] Android toolchain - develop for Android devices
    ✗ ANDROID_HOME = C:\Users\[...]\AppData\Local\Android\Sdk
      but Android SDK not found at this location.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.5)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31729.503
    • Windows 10 SDK version 10.0.19041.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[✓] VS Code, 64-bit edition (version 1.81.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.2134]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 116.0.5845.141
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 116.0.1938.69

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
@IVLIVS-III
Copy link
Owner

Yes, this is to be expected, unfortunately.
I intentionally develop this project first on macOS, and once I have it working on that platform, I start porting things to Windows and Linux.
At this point in time, the project requires a custom Python compilation which I haven't done for Windows. Thus caching the Python runtime fails, since it doesn't exist yet. As indicated in the Readme Windows support is declared as "sometimes works on my machine". This is very experimental. See also the discussion in #7.

@IVLIVS-III IVLIVS-III added bug Something isn't working blocked This issue will be addressed later. labels Sep 5, 2023
@bmsrangel
Copy link
Author

Yes, this is to be expected, unfortunately.
I intentionally develop this project first on macOS, and once I have it working on that platform, I start porting things to Windows and Linux.
At this point in time, the project requires a custom Python compilation which I haven't done for Windows. Thus caching the Python runtime fails, since it doesn't exist yet. As indicated in the Readme Windows support is declared as "sometimes works on my machine". This is very experimental. See also the discussion in #7.

Yes, I found that information in the README. I was hoping that maybe it would work in mine as well.

I've seen #7, but as error messages were different and there was no other information provided, I decided to report my case

@IVLIVS-III
Copy link
Owner

Thank you for reporting this.
The null\.dartpip… cache location is definitely something I haven't seen yet. Will resolve it when working on Windows again.

@anushkavidanage
Copy link

Any updates or workaround for this issue? I am getting the same PythonFfiException: Failed to cache Python runtime for version 3.11.3 on windows error in Windows environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked This issue will be addressed later. bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants