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.
-
Use an external software package like [cx_Freeze](http://cx-freeze.sourceforge.net/). – Matthias Sep 28 '13 at 21:43
-
PyCharm does not have this feature yet, but have you tried this? http://www.py2exe.org/ – Shashank Sep 02 '21 at 03:44
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.

- 58,192
- 30
- 175
- 224
-
3So it looks like none of the python IDE's (pycharm or pydev - eclipse pluggin) have yet to incorporate the compile-to-single-executable functionality into the IDE itself. If this is not the case, please let me know. :-) – Nelda.techspiress Oct 26 '16 at 16:30
-
3Related: [Configuring Pycharm to run Pyinstaller](https://stackoverflow.com/q/33906539/3357935) – Stevoisiak Apr 09 '18 at 18:58
-
You can include "--onefile": pyinstaller myscript.py --onefile to have only one big .exe file – Vandre Sep 22 '22 at 21:00
-
Can you convert to .EXE using PyCharm free edition, or do you need the paid version? – Sabatino Ognibene Oct 07 '22 at 21:12