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

Linux builds break PyInstaller #276

Open
alexdelorenzo opened this issue Jul 10, 2024 · 3 comments
Open

Linux builds break PyInstaller #276

alexdelorenzo opened this issue Jul 10, 2024 · 3 comments

Comments

@alexdelorenzo
Copy link

I installed the portable Python 3.12.3 build like so:

$ rye toolchain fetch cpython@3.12.3
$ rye init
$ rye pin cpython@3.12.3

Rye downloads and uses the IndyGreg Portable Python builds

Basic case to reproduce

Create the base case file:

# main.py
print("hello world")

Run PyInstaller on the file:

$ python -m pip install PyInstaller
$ python -m PyInstaller --onefile main.py

Then run the compiled binary:

$ dist/main
[1475051] Module object for struct is NULL!
Traceback (most recent call last):
  File "struct.py", line 13, in <module>
ModuleNotFoundError: No module named '_struct'

The expected result, using the system Python, is:

$ dist/main
hello world
@zanieb
Copy link
Collaborator

zanieb commented Jul 10, 2024

Thanks for the report. Vaguely looks this module should be present, e.g., 60d4e65. I'm not sure what's going on — I'm not particularly familiar with how PyInstaller works.

@alexdelorenzo
Copy link
Author

No problem. I can try to dig deeper when I have some time.

I can confirm that the Portable Python builds for x86_64 macOS and Windows don't have this problem, they work fine with PyInstaller. Seems to just be the Linux (x86_64, at least) builds.

@alexdelorenzo
Copy link
Author

Tried on a fresh Ubuntu 24.04 VM using the following main.py:

import multiprocessing
print("hello world")

Then followed the steps in the OP to compile dist/main:

$ dist/main
Traceback (most recent call last):
  File "PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py", line 107, in <module>
  File "PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py", line 95, in _pyi_rthook
  File "PyInstaller/loader/pyimod02_importers.py", line 419, in exec_module
  File "multiprocessing/popen_forkserver.py", line 7, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 419, in exec_module
  File "multiprocessing/forkserver.py", line 11, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 419, in exec_module
  File "multiprocessing/connection.py", line 22, in <module>
ModuleNotFoundError: No module named '_multiprocessing'
[13284] Failed to execute script 'pyi_rth_multiprocessing' due to unhandled exception!

Looks like C modules from the standard library are tripping up PyInstaller on Linux with the Portable Python builds, it's not just _struct that's the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants