0

I have been trying to convert my .py to .exe. Unfortunately, I haven't been successful. After pip install py2exe and using build_exe myscript.py I get multiple errors such as the following:

\...\py2exe\mf3.py", line 120, in import_hook
    module = self._gcd_import(name)
\...\py2exe\mf3.py", line 274, in _gcd_import
    return self._find_and_load(name)

I don't understand what this mean. Does it mean there is something wrong with my code? (Weird, cause it runs perfectly). Or is it just py2exe that can't do it?? Thanks a lot

2
  • check pyinstaller Commented Feb 14, 2018 at 19:49
  • Hi! Please show complete error log. Thanks. Commented Feb 14, 2018 at 19:50

1 Answer 1

3

I'm not sure about py2exe. I use pyinstaller for creating .exe and it works just fine.

pip install pyinstaller
pyinstaller --onefile filename.py

And that's it. Your .exe is in the dist folder (dist is created automatically by pyinstaller in the directory where the .py file is).

If you don't want a console (if you have a GUI / writing a background process / have no use for I/O or stderr),

pyinstaller --onefile --noconsole filename.py

If you want a customized icon,

pyinstaller --onefile --noconsole -i iconfile filename.py

Edit: The --noconsole switch is ignored in Linux as far as I know.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.