Search code examples
python-3.xcx-freezepython-3.9

cx_Freeze ConfigError: No file named C:\Python\Scripts\cxfreeze.exe\__main__.py (for module __main__)


I would like to create a .exe file of a file named ZCasinoinsulte.py located in C:\Python\Scripts. Moreoever, every time I execute cxfreeze ZCasinoinsulte.py it never works and tells me it does not find _main_.py in cxfreeze.exe.

Specs: I have python 3.9.1 on Windows 10 64bit.
I have installed cx_Freeze-6.5.1 with whl.
It does create an exe file, but it opens and shuts down instantly (even though I put os.system("pause") in ZCasinoinsulte.py).

old code

Any help would be appreciated :D

Edit: I have used the cxfreeze version 6.4.2 and the code runs better without errors. But the exe file closes as soon as I clic on it. Here is my pip list traceback:



C:\Users\Hmili>pip list
Package            Version
------------------ -------
cx-Freeze          6.4.2
importlib-metadata 3.4.0
pip                20.3.3
setuptools         49.2.1
zipp               3.4.0

Here is the traceback when I execute the exe file from cmd:


C:\Python\Mes fichiers python\dist>ZCasinoinsulte.exe
Traceback (most recent call last):
  File "c:\python\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 41, in run
    module.run()
  File "c:\python\lib\site-packages\cx_Freeze\initscripts\Console.py", line 36, in run
    exec(code, m.__dict__)
  File "ZCasinoinsulte.py", line 3, in <module>
  File "c:\python\lib\site-packages\cx_Freeze\__init__.py", line 1, in <module>
    import setuptools
  File "c:\python\lib\site-packages\setuptools\__init__.py", line 24, in <module>
    from setuptools.depends import Require
  File "c:\python\lib\site-packages\setuptools\depends.py", line 6, in <module>
    from .py33compat import Bytecode
  File "c:\python\lib\site-packages\setuptools\py33compat.py", line 11, in <module>
    from setuptools.extern.six.moves import html_parser
  File "c:\python\lib\site-packages\setuptools\_vendor\six.py", line 92, in __get__
    result = self._resolve()
  File "c:\python\lib\site-packages\setuptools\_vendor\six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "c:\python\lib\site-packages\setuptools\_vendor\six.py", line 82, in _import_module
    __import__(name)
ModuleNotFoundError: No module named 'html.parser'

Here are the first ten lines of ZCasinoinsulte.py:

# -*-coding:Latin-1 -*
import os,time
from cx_Freeze import setup, Executable

from random import randrange
argent=3000
while argent>0:
    condition1=0
    condition2=0
    argent=int(argent)
    

How do I resolve this? (Thanks for the help by the way :) )


Solution

  • First I downgraded pip as James Mackey advised me. The code ran properly and created an exe file. So the first issue was a comptability one.

    Moreover, the exe file created crashed instantly when executed. From the traceback of the execution of ZCasinoinsulte.exe with cmd, James Mackey figured the third line of ZCasinoinsulte.py had an error related to it.

    The third line of ZCasinoinsulte.py was:

    from cx_Freeze import setup, Executable
    

    I erased this line as it has nothing to do with the actual code. I opened cmd and executed again the command: cxfreeze ZCasinoinsulte.py. The exe file now functions properly.