Search code examples
pythonmoduleoperating-systempyinstallercx-freeze

Converting .py to .exe - no os module


I tried to convert my .py file to .exe with pyinstaller and cx_Freeze but in both cases it says ModuleNotFoundError: No module named 'os'. I have installed os and I am testing the .exe file on same PC as .py file. I do not think any code is relevant but if it is let me know and I will update it. I also included os under packages while using cx_Freeze. EDIT:

Traceback (most recent call last):
File "<frozen zipimport>", line 259, in load_module
File "C:\path\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 7, in <module>
import os
ModuleNotFoundError: No module named 'os'

I also get this when converting with cx_Freeze:

:208: SyntaxWarning: "is" with a literal. Did you mean "=="?
if setting is None or setting is '':

Solution

  • If you are still using cx_freeze under build_exe_options do not include the os as a package.