-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
/usr/bin/python3: can't find '__main__' module in 'blah.pex' #958
Comments
Okay, I recently had this problem as well and it turns out that python doesn't know how to handle .pex files that are larger than 2gb in size and that gives you the incredibly useful "Can't find main" error. |
Sorry to see this so late - thanks for the bump with data @tentwelfths. Perhaps you could try the next Pex release or Pex master which now support a |
Specifically, |
@tentwelfths I repro, although I get a different error message:
But the
|
There is also |
That's the default for all versions of Python Pex supports save 2.7. IOW building @tentwelfths PEX file would have failed in the 1st place if using 2.7 implying they used 3.x. It seems like an issue not in the zipfile stdlib but in CPython c code that implements zipimport. IE, changing my repro above a bit I get:
|
I'm going to guess the CPython code doesn't re-implement zip but links ziplib and that's where the variance @dgkatz noted comes from. Some versions of ziplib support this and some don't ... that seems likely anyhow. |
Eek - I was living a fantasy. The zipimport lib is written in Python and does not track the zipfile stdlib. https://github.com/python/cpython/blob/3.9/Lib/zipimport.py#L360 - so it just gets this wrong and assumes 32 bit straight up. So this does not explain the @dgkatz works someplaces and not others OP, but we never had clinching evidence that the @tentwelfths issue was exactly the @dgkatz issue anyhow. |
And .. that zipimport shortcoming is documented here: https://bugs.python.org/issue32959 |
I'm trying to put torch in a pex and hitting this problem since torch unzipped is 3GB, and zipped a bit more than 2GB |
@rom1504 it depends what you want to do with the PEX. Since you'll already have to split it in 2 and have more than 1 file to ship around, perhaps you're ok with There were a few hot fixes after the initial release here: https://github.com/pantsbuild/pex/releases/tag/v2.1.48 but its been stable for a while now and is used by stable Pants for example for all the internal PEXes it creates to improve caching characteristics. For example:
|
thanks! |
Ok, I have not used Spark before, but I'd guess you want the following config tweaking their example:
|
I confirm the --layout packet mode worked to produce this .pex folder (containing one wheel file per dependency) and I was able to run the |
It's indeed working well for my use case, thanks for the suggestion! It seems this new format could be quite adapted to splitting the building process in several parts, and building each part independently, and maybe even in parallel, speeding up the pex generation, which can take several minutes today. |
@rom1504 Pex does already build in parallel using your number of cores by default (see
|
@dgkatz - finally looping back. was your issue related to the huge PEX issue @tentwelfths and @rom1504 encountered (>2GB PEX)? If so, I'd like to close this issue since @rom1504 confirms the @tentwelfths hopefully |
I just encountered a similar issue w/ a pex file that was ~700M (lower than the 2G reported earlier in this issue). Using |
pex-tool/pex#958 This allows seamlessly use the env with archive distribution system, e.g. spark.yarn.dist.archive
@rahul-theorem there are (at least) 2 axes which can cause a zip to use ZIP64 extensions: size and entry count. If there are >2^16 files in the zip, it will use ZIP64 extensions and won't boot under Python<3.13. |
I'm going to close this as an answered question. In the meantime two things have improved:
|
I have a pex file which i build via the following command:
pex -v -r requirements.txt -c gunicorn -D . -o blah.pex
which contructs a pex, installing requirement, and all files in project, setting entrypoint to gunicorn.
Build process works just fine. but when it comes time to run the pex, depending on where i run it ubuntu vm/ mac local/ ubuntu docker sometimes i get the following error:
/usr/bin/python3: can't find '__main__' module in 'blah.pex'
When I unzip the pex, i do see a main.py file in there, so im not sure what the problem is.
Has anyone experience this error? Ideas on what the problem is?
The text was updated successfully, but these errors were encountered: