[ python-Bugs-1011893 ] Problems importing packages in ZIP file

SourceForge.net noreply at sourceforge.net
Mon Aug 23 01:01:09 CEST 2004


Bugs item #1011893, was opened at 2004-08-19 13:17
Message generated for change (Comment added) made by dennis_cs_chuah
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1011893&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Dennis Chuah (dennis_cs_chuah)
Assigned to: Nobody/Anonymous (nobody)
>Summary: Problems importing packages in ZIP file

Initial Comment:
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.



----------------------------------------------------------------------

>Comment By: Dennis Chuah (dennis_cs_chuah)
Date: 2004-08-23 11:01

Message:
Logged In: YES 
user_id=700058

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 ('test2.zip', 'w', zipfile.ZIP_DEFLATED)
z.writepy ('test')
z.close()

It should have created a test2.zip archive.

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

import sys
sys.path.append ('c:\Python23\test2.zip')
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 
fine.


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-08-20 19:24

Message:
Logged In: YES 
user_id=21627

Can you please attach a small sample ZIP file that
demonstrates the problem? I don't have the PKZIP command
line tool.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1011893&group_id=5470


More information about the Python-bugs-list mailing list