py2exe excluding a module, and import it during runtime, how?

Satya Nanda Vel Arjunan satya at ttck.keio.ac.jp
Wed May 5 11:50:04 EDT 2004


Hi, I think there must be a simple solution for this problem, but I
couldn't find any example of this problem when I searched for it. I am
using py2exe-0.5.0. I would like to make a simple script, test.py into
an exe file, test.exe. In test.py I import a custom module called emc:

import sys
import os
import emc

def main():
    aProgramName = os.path.basename( sys.argv[0] )
    
if __name__ == '__main__':
	main()


I would like to exclude the emc module when creating the exe file. To
do this I used the following setup.py:
from distutils.core import setup
import py2exe

setup( 
	windows=[ { "script": "test.py" } ],
	options={ 'py2exe': { 'excludes' : ['emc'] } }
)

When I run the test.exe I get the following error:
ImportError: No module named emc

I have tried putting the module emc.py in the same directory as
test.exe and but it could not load it. So far I have only been
successful if I include emc.py inside the library.zip file, which I do
not want to do. How do we import a module only during runtime if we
exclude it when creating the exe file? I need this feature because
some modules are not readily available during the creation of the exe
file. Thank you for any pointers.

satya



More information about the Python-list mailing list