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.

Title: Problems importing packages in ZIP file
Type: Stage:
Components: None Versions: Python 2.3
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: alanmcintyre, dennis_cs_chuah, loewis
Priority: normal Keywords:

Created on 2004-08-19 01:17 by dennis_cs_chuah, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit dennis_cs_chuah, 2004-08-22 23:01 Sample package code that does not import
Messages (8)
msg22132 - (view) Author: Dennis Chuah (dennis_cs_chuah) Date: 2004-08-19 01:17
Python 2.3.2 Windows platform

Python is unable to import modules in ZIP files created 
by the PKZIP command line tool, version 2.50.

msg22133 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-08-20 07:24
Logged In: YES 

Can you please attach a small sample ZIP file that
demonstrates the problem? I don't have the PKZIP command
line tool.
msg22134 - (view) Author: Dennis Chuah (dennis_cs_chuah) Date: 2004-08-22 23:01
Logged In: YES 

More information.

It would appear that the problem is not PKZIP's command line 
archiver as it also happens with ZIP archives created with the 
zipfile module.  Rather the problem has something to do with 
packages in ZIP file.  To reproduce this problem:

1.  Create a sub-directory under c:\Python23 (or whereever 
you installed Python) named test.
2.  Unzip the files from the ZIP archive into the directory.
3.  Start the command line interpretor and enter:

from test import testing

Should display "test"

4.  Exit the command line interpretor.
5.  Delete all *.pyc files from the test directory.
6.  Restart the interpretor and enter the following:

import zipfile
z = zipfile.PyZipFile ('', 'w', zipfile.ZIP_DEFLATED)
z.writepy ('test')

It should have created a archive.

7.  Exit the interpretor.
8.  Verify that contains two pyc files inside the test 
9.  Restart the interpretor and enter the following:

import sys
sys.path.append ('c:\\Python23\\')
from test import testing

You should get:
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: cannot import name testing

Now, if you created a ZIP archive, with the PY files, it imports 
msg22135 - (view) Author: Dennis Chuah (dennis_cs_chuah) Date: 2004-08-22 23:02
Logged In: YES 

Changed summary to better reflect what the problem is.
msg59408 - (view) Author: Alan McIntyre (alanmcintyre) * (Python committer) Date: 2008-01-06 21:54
I just tried out this test with the trunk and 2.5.2 from svn (on OS X,
not sure if that might make a difference), and didn't get the reported
error.  Since the issue has apparently been fixed at some point, is
there any reason not to close this issue?
msg59440 - (view) Author: Dennis Chuah (dennis_cs_chuah) Date: 2008-01-07 10:23
I had forgotten about this bug.  I haven't been able to test this on 
2.5 as I have not worked with Python for a while.  I think if you are 
satisfied that the problem doesn't exist, then close it.  If I find it 
again, I can certainly log the problem again.  BTW, did you manage to 
test whether the problem existed in the version that I reported it in?
msg59451 - (view) Author: Alan McIntyre (alanmcintyre) * (Python committer) Date: 2008-01-07 15:31
I just tried it on 2.5 and 2.6, since I didn't have the earlier versions
available.  If I find some time I'll see if I can try it on 2.3 & 2.4;
maybe that will shed some light on whether it's been fixed or if is
something specific to Windows that could still be broken.
msg78521 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-12-30 11:54
It seems most people agree that this "works for me".
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40785
2008-12-30 11:54:20loewissetstatus: open -> closed
resolution: works for me
messages: + msg78521
2008-01-07 15:31:19alanmcintyresetmessages: + msg59451
2008-01-07 10:23:24dennis_cs_chuahsetmessages: + msg59440
versions: + Python 2.3
2008-01-06 21:54:46alanmcintyresetnosy: + alanmcintyre
messages: + msg59408
2004-08-19 01:17:59dennis_cs_chuahcreate