I have implemented a package names myUtils, it consists of folder 'myUtils', file 'init.py' and a number of *.py files with names != 'myUtils'. This package is included in myOtherProject.py and can be found/used when I run them from Eclipse.
However, when I run py2exe on myOtherProject.py, resulting exe cannot find this module(error message "ImportError: no module named myUtils"). Trimmed version of my setup.exe:
from distutils.core import setup
import py2exe, sys
sys.path.append(pathTo_myUtils)
import myUtils # this line works fine even if I comment out sys.path.append(...)
data_files_ = (('.', ["C:\\Python27\\DLLs\\MSVCP90.dll",
"C:\\Python27\\lib\\site-packages\\Pythonwin\\mfc90.dll"]))
setup(windows=['myOtherProject.py'], options={'py2exe': {'excludes': ['tcl'], 'includes': ['myUtils'], 'dll_excludes': ['tk85.dll', 'tcl85.dll'] }}, data_files=data_files_)
How could I fix this? I am using Python 2.7 on WinXP.
I did not define PYTHONPATH properly; there were spaces after semicolons. Instead of
c:\aa\; c:\bb\; c:\cc\
it needed to be
c:\aa;c:\bb;c:\cc
For packages that are defined using init.py (package MyPackage corresponds to a folder MyPackage, that contains init.py and some other files, without MyPackage.py), path that I needed to add to PYTHONPATH was not
<path_to_MyPackage>\MyPackage
but just
<path_to_MyPackage>
...