How can I convert .py to .exe? - python

Recently, I found pingpong game made by pygame and I am trying to convert it into .exe file but i can't. this is the link of the code I am trying to convert. https://algorithm.joho.info/programming/python/pygame-pong/ (this site is japanese, the code is at middle)
Thank you for your helps!!

pyinstaller is compatible with up to python 3.6.
Install PyInstaller from PyPI:
pip install pyinstaller
Go to your program’s directory and run:
pyinstaller yourprogram.py

There are different tools for converting a python script into an executable. For example:
http://py2exe.org/

Related

Python standalone executable

I want to be able to create a Python standalone executable without any dependencies. Basically, an executable that is closed-source so that anyone end-user/client can use my application.
I am aware of the module py2exe; however, it appears that you need some of the .pyc files with it to actually run the .exe file.
I am using Python 2.7.x
Any help would be greatly appreciated.
Check PyInstaller. This is an alternative to py2exe
http://www.pyinstaller.org/
pip install pyinstaller
pyinstaller yourprogram.py

How do I install Enchant on Anaconda Windows via a tar.gz download?

Thanks for reading: please forgive how rubbish I am at dealing with installations.
I want to install Enchant on Windows in my Anaconda Python distribution.
It is available from this website: http://pythonhosted.org/pyenchant/download.html
There is a .gz file and a .exe file.
I am not able to use the .exe as the inbuilt installer does not detect the correct python distribution on my computer (I have separate installs of 2.7/3.5/Anaconda 4.2).
I download the file enchant-1.6.0.tar.gzto my downloads folder.
Now: what exactly do I do now to install it in Windows into my Anaconda Python distribution? I tried unzipping it but there are no executables within it. Do I have to do something via CMD or Anacaonda Command Prompt?
Any help much appreciated.
Edit: To be clear, I have already installed Pyenchant. It is enchant that I cannot install.
Edit: There are a ton of files within the zip download including three different configure files, install-sh (for Linux?). How do I use what is there either within CMD or otherwise?
Edit: Looks like Enchant only works on 64 bit Python. Could this be why the auto exe installer does not detect my Anaconda distribution, or do I have to tell it where to look?

Convert script to executable, python not in registry

I am trying to convert a python script to an executable file.
I have tried cxFreeze and py2exe, but both told me that Python27 are not in the registry. I found several other questions that tell me to go to regedit and find the python folder, but it is not there. I tried going to HKEY_CURRENT_USER/Software and Python27 was not there.
Do I need to add it there to run the installer for cxFreeze or py2exe or is there another way?
Tools like PyInstaller package python scripts with the python run-time interpreter into standalone Windows applications. Installation of python (2.7.x) and all required python libraries is a prerequisite.
My suggestion is to install the latest Python 2.7 from this location: https://www.python.org/downloads/release/python-2710/. Make sure to choose the correct architecture, apparently 32-bit is the easiest to get working.
I fixed the issue. Apparently I accidentally installed 32-bit Python on a 64-bit machine. So I have to use the 32-bit installer because it installs the registry key in a different place. Thanks for the help anyways.

Use Python without installing

I have an installer which uses a Python script to install several components. I do not want to install Python on the users computer if they do not already have it and I also do not want having Python installed to be a prerequisite for using my installer. Is there a way of downloading Python without using the installer and just running it from a directory which can be easily removed after the installation is complete?
Portable Python is an easy tool to use on Windows. If you want to create .exe programs use PyInstaller to compile them. They can both work on top of each other, you can compile (make .exes) using Portable Python, Portable Python 3 is also available.
If the installer is for OS X or Linux, Python shall be there usually. Otherwise
Lazy way: Detect if Python is existed. If not, ask user to install it as dependency. e.g. A link for python download page.
Rewrite your script. If the logic is not complicated, use some other build-in shell script is a good idea.
Static linking Python. Yes, static linking is evil. However, it's still an option.
Found some project maybe helpful on github and google-code
(In addition to Owens points). Use py2exe or one of the other exe builder utils for python on windows. On other platforms just use the python script.
Try cx_Freeze
This program can freeze your python code into a .exe file and some other pyd files, it can be run without installing python.
NOTE: You will need to install python to freeze, but you don't need python to run the program.
You can download from here.
https://anthony-tuininga.github.io/cx_Freeze/index.html
TO FREEZE:
make a file setup.py
type
from cx_Freeze import setup, Executable
setup (name='NEW_EXE_FILE_NAME',
executables = [Executable("xx.py")])
xx.py will be the python code you want to freeze.
command line: python setup.py build
You can use python's embeddable package, available here:
Python Windows Releases
Once you download the package all you need to do is extract it into a folder. That's it... Installed.
You also might want to install pip to manage packages by running the pip install script pip install script and add pip.exe's relative path to python3xx._pth file.
PatriTech made a nice summary of the process on YouTube: Embedded Python Installation

setup.py is not yet supposed to work. Please Use PyInstaller without installation

I am a mac user trying to make my pygame game available for windows as an exe so bear with me. I am trying to use pyinstaller but when I run setup.py it gives me the error:
setup.py is not yet supposed to work. Please Use PyInstaller without installation.
I have tried installing it with pip as well but get the exact same thing. I am aware of this post:
pyinstaller setup failed with "setup.py is not yet supposed to work. Please Use PyInstaller without installation." or though (being pretty noobie) I cant get a solution from the answer. Is there a fix?
Go here. Download whichever version you want. Unzip the archive. In a console/terminal with admin access go to the directory that contains your unzipped contents. Then do:
python setup.py install. That should install pyinstaller for you. Test it out to make sure pyinstaller has been added to your PATH so that you can run it from any directory.
After you have installed Pyinstaller using setup.py, go to the directory with your game in it and do pyinstaller game.py.
For more information, check out the official documentation which explains how to use setup.py to install from an archive.
Solved! I installed the development version after finding this ticket:
http://www.pyinstaller.org/ticket/756
and now all works fine.

Categories

Resources