To be clear, this is my test.py code:
#######################
import sys, zipimport
zip = “WEB/python/test.zip”
if zip in zipimport._zip_directory_cache:
del zipimport._zip_directory_cache[zip]
sys.path.insert(0, zip)
#import sys
#APP_ARCHIVE = “WEB/python/test.zip”
#sys.path.insert(0, APP_ARCHIVE)
#sys.path.append(‘WEB/python/test.zip’)
print sys.path
#import fibo.fib
from fibo import fib, fib2
#################
and this is the fibo.py file in test.zip:
####################
Fibonacci numbers module
def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while b < n:
print b,
a, b = b, a+b
def fib2(n): # return Fibonacci series up to n
result = []
a, b = 0, 1
while b < n:
result.append(b)
a, b = b, a+b
return result
#################
And here is what I get when I run it.
#> python test.py
[‘WEB/python/test.zip’, ‘WEB/python’, ‘WEB/python/python.zip’]
Traceback (most recent call last):
File “”, line 20, in ?
ImportError: No module named fibo
#>
So clearly the path has been modified properly, but for some reason it doesn’t seem to be actually looking in the zip file. When I include fibo.py in the WEB/python directory, it runs fine. Can someone please tell me what I’m missing here?
Thanks in advance.
-Mike-