Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting .py to .exe with Anaconda

I made a python program using PyGame which is only available for Python 2.7 so that is my python version. I am using Anaconda because it is easier to install modules and to use python, but the site hasn't py2exe module for 2.7. Is there another way to convert it? Or some way to install py2exe for 2.7 in Anaconda?

like image 649
Luis Dias Avatar asked May 20 '17 18:05

Luis Dias


People also ask

Can Python be compiled to exe?

Yes, it is possible to compile Python scripts into standalone executables. PyInstaller can be used to convert Python programs into stand-alone executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris, and AIX. It is one of the recommended converters.

How do I convert a file to exe?

Select All Files from the "Save as type" menu. 4. Name the file "filename.exe" and click Save.


2 Answers

How to create an executable using Anaconda 3 (specifically Anaconda Prompt) for Windows.

1 - Make sure pyinstaller is installed in your anaconda

pip install pyinstaller

2 - Move to the directory of your python script

cd C:\Users....\program.py

3 - Just type the following:

pyinstaller --onefile program.py

If everything goes well, in the folder where you have your script.py you it will be created many folders and your executable is inside folder "dist".

If my explanation is confusing go here: https://medium.com/dreamcatcher-its-blog/making-an-stand-alone-executable-from-a-python-script-using-pyinstaller-d1df9170e263

like image 76
Rui Filipe Avatar answered Oct 09 '22 14:10

Rui Filipe


Instead of using py2exe you could try to build your executable with pyinstaller.

http://www.pyinstaller.org/downloads.html

The PyGame package is also supported with pyinstaller according to this link

https://github.com/pyinstaller/pyinstaller/wiki/Supported-Packages

like image 37
Marcel S. Avatar answered Oct 09 '22 14:10

Marcel S.