Search code examples
pythonpy2exe

Python py2exe Not Including `os` Module


I have a python program which imports os so that I can retrieve the application's path (i.e. os.path.dirname(os.path.realpath(__file__))). I have been using py2exe to make this python file into an exe, and I have had no issues until I started to use os. Here is the command window (notice it says 1 missing Modules): enter image description here

When I try to open the .exe that gets created, it closes on me immediately. All the other imports seem to work fine, and they are: win32api, win32con, time, msvcrt, win32gui, re. Again, the .exe stops working properly when I import os but the Python project itself works fine. What can I do to fix this? Thanks.


Solution

  • Use cx-Freeze for create a .exe on windows instead of py2exe.