Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to my "exe" from PyCharm project [duplicate]

Writing some project on Python via PyCharm. I want to get an exe file from it. I've tried to "Save as->XXX.exe" - but ,when i'm trying to execute it there is an error "file is not supported with such kind of OS" p.s. i've got win7 x64,it doesn't work on x32 too.

like image 400
Anton Bondar Avatar asked Sep 28 '13 21:09

Anton Bondar


1 Answers

You cannot directly save a Python file as an exe and expect it to work -- the computer cannot automatically understand whatever code you happened to type in a text file. Instead, you need to use another program to transform your Python code into an exe.

I recommend using a program like Pyinstaller. It essentially takes the Python interpreter and bundles it with your script to turn it into a standalone exe that can be run on arbitrary computers that don't have Python installed (typically Windows computers, since Linux tends to come pre-installed with Python).

To install it, you can either download it from the linked website or use the command:

pip install pyinstaller

...from the command line. Then, for the most part, you simply navigate to the folder containing your source code via the command line and run:

pyinstaller myscript.py

You can find more information about how to use Pyinstaller and customize the build process via the documentation.


You don't necessarily have to use Pyinstaller, though. Here's a comparison of different programs that can be used to turn your Python code into an executable.

like image 112
Michael0x2a Avatar answered Sep 22 '22 15:09

Michael0x2a