Hello, I have a code that I did in python and uses some libraries. I would like to know if it is possible to make an executable for this program and the user who uses it does not need to have python or these libraries installed.
Hello, I have a code that I did in python and uses some libraries. I would like to know if it is possible to make an executable for this program and the user who uses it does not need to have python or these libraries installed.
It looks like you want to compilar
your source code into an executable.
If your code was written to python 2.x ou 3.0-3.1
, you can use, for example, the library py2exe
.
To create the executable, you should:
install py2exe
( pip install py2exe
)
Have the code to be compiled saved on the computer (for example, code hello.py
)
Create a file named setup.py
in the same folder as the code to be compiled, with the following content:
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
Navigate the terminal to the folder with the files ( hello.py
and setup.py
) and run the command python setup.py install
Ready. The folder should have been created 2 new folders. In one of them you will find your .exe
.
NOTE:
Python 2.6, 2.7, 3.0 ou 3.1
, you should be aware that py2exe
does not automatically include DLL
MSVCR90.dll
in dist
, so you should put it there manually. If your code was written to python 2.7 ou 3.3—3.5
, you can use, for example, the library PyInstaller
.
To create the executable, you should:
Install package pyinstaller
( pip install pyinstaller
)
To create the .exe, navigate through the terminal to the folder with the code to compile and type:
pyinstaller --onefile script.py
Ready.