This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lfamorim
Recipients lfamorim
Date 2021-10-22.16:40:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634920833.59.0.789504609207.issue45576@roundup.psfhosted.org>
In-reply-to
Content
I've tried to import a module from a fat jar file and got a ModuleNotFoundError: No module named ... error.

I checked that the jar file had more than 65k files and was created using Zip64. When I unzip the file, Python is capable of importing the modules.

I was able to reproduce the error on a simple project, such as:

simplePackage/
  __init__.py
  a/
    __init__.py
    moduleA.py

where

- I'm using Python 3.9.4
- __init__.py files are empty
- moduleA.py only has a printA() function

I ran the following tests:

1. When importing from the folder, it works

python
>>> import sys
>>> sys.path.append('C:\\Users\\...\\simplePackage')
>>> from a.moduleA import printA
>>> printA()
I'm module a

2. When zipping the folder, it works

python
>>> import sys
>>> sys.path.append('C:\\Users\\...\\simplePackage.zip')
>>> from a.moduleA import printA
>>> printA()
I'm module a

3. When forcing to zip with Zip64 it doesn't work

On linux: zip -fzr simple64Package.zip .

python
>>> import sys
>>> sys.path.append('C:\\Users\\...\\simple64Package.zip')
>>> from a.moduleA import printA
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'a'

Is this an expected behavior? Am I missing something?

Thanks!
History
Date User Action Args
2021-10-22 16:40:33lfamorimsetrecipients: + lfamorim
2021-10-22 16:40:33lfamorimsetmessageid: <1634920833.59.0.789504609207.issue45576@roundup.psfhosted.org>
2021-10-22 16:40:33lfamorimlinkissue45576 messages
2021-10-22 16:40:33lfamorimcreate