7
Hello, I have a code I made in python and it uses some libraries. I wonder if it is possible to make an executable for this program and q user q uses it n need to have python or these libraries installed.
7
Hello, I have a code I made in python and it uses some libraries. I wonder if it is possible to make an executable for this program and q user q uses it n need to have python or these libraries installed.
11
Looks like you want to compilar
your source code in an executable.
If your code has been written to python 2.x ou 3.0-3.1
, you can use, for example, the library py2exe
.
To create the executable, you must:
install the py2exe
(pip install py2exe
)
have the code to be compiled saved on the computer (for example the code hello.py
)
create a file called 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'])
Browse the terminal to the folder with the files (hello.py
and setup.py
) and rotate the command python setup.py install
Done. In the folder 2 new folders must have been created. In one of them you will find yours .exe
.
OBS:
1) You can see in the documentation more parameters to add when compiling;
2) If your code has been written to Python 2.6, 2.7, 3.0 ou 3.1
, you should pay attention to the fact that the py2exe
does not automatically include the DLL
MSVCR90.dll
in the briefcase dist
, so you should put it there manually.
If your code has been written to python 2.7 ou 3.3—3.5
, you can use, for example, the library PyInstaller
.
To create the executable, you must:
Install the 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.
Browser other questions tagged python
You are not signed in. Login or sign up in order to post.
Specify your problem better so that users can help you. If I can put the code you’ve tried so far it’s even better.
– Asura Khan