Use zipimport.
>>> import sys
>>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path
>>> import foobar
题
am using a python scripts in c/c++ program and i want to import python packages from a zip file as in Sublime Text, is there a better way to do it?
解决方案
Use zipimport.
>>> import sys
>>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path
>>> import foobar