SITUATION:
- You have a "main script" that calls "other scripts" (in the same
folder or in packages) created by yourself.
SHORT ANSWER:
It removes the name of the script, and adds the folder to the PYTHONPATH.
LARGE ANSWER:
(The explanation about how to arrive to the conclusion)
How can you test that py2exe can't find your "other scripts"?
- Run py2exe with a simple .bat file that contents cd commands to find
setup.py, the run command, and a wait time command that allows you to
read the output information in the console after.
cd..
cd..
cd..
cd..
cd..
cd Folder1
cd Folder2
"C:\Python27\python.exe" setup.py py2exe
>nul ping -n 30 localhost
- You can find now a warning like "The following modules appear to be
missing" (use right click > find if you want)
Why did it happen?
- Py2exe looks for "other scripts" similar to import function (in the
modules already imported, the main script folder, pythonpath's
directories, etc). However, py2exe omits the main script folder
(maybe it's a bug). That's why you won't have problems if you copy
your "other scripts" in site-packages folder, for example.
How can you solve this?
You have to add the main script directory to the pythonpath:
- (not recommended) ‎If you modify it with control panel the changes
will remain after the program closes.
(like this: How to add to the pythonpath in windows 7?)
- (recommended) If you modify it with code (following the steps
detailed above in the short answer), the changes will remain only
until the program closes.
Good luck!