How to convert python script to exe Without additional files - python

I want to convert my python script to exe without additional files like ddl, pyd..
Is it possible?

Use pyinstaller https://github.com/pyinstaller/pyinstaller
Install it by running pip install pyinstaller in terminal / console
Then run pyinstaller --onefile yourscriptsname.py and it will create you an exe file in the same directory

Related

How to create exe of project who has .cxx .py file and many dlls

I have a code who is depended on Qt, PyQt, VTK, ITK, libs.
using CMAKE to build
Environment : Windows
I want to distribute EXE who has cxx, py files and related dlls
I have tried to compile and got executable but my python files are remaining necked.
I don't want to share python files as a script.
how we can make those python files as a dlls
python is often a hard language to turn to exe but the best way to do so is using the pyinstaller package. Installed by pip install pyinstaller and can turn a .py file to a .exe by pyinstaller --onefile FILENAME.py in CMD. After that your exe file should be stored in a folder called disk. The other files can just be included in the same file as the exe.
docs: https://pyinstaller.org/en/stable/

I can't convert pygame to exe

I made an app for my friends but I can't make executable file. I tried to use pyinstaler and cx_Freeze but it didn't worked. It creates properly an exe file but It doesn't work. When I try to run executable It pops out empty cmd window and disapears without any error.
Im working on python 3.7.4.
There is code that I used to create exe with cx Freeze:
import cx_Freeze
executables = [cx_Freeze.Executable("GenshinHelper.py")]
cx_Freeze.setup(
name="GenshinHelper",
options={"build_exe": {"packages":["pygame",'datetime'],
"include_files":['img1.jpg','img2.jpg']}},
executables = executables
)
Here is one way t do that;
first install pyinstaller;
pip install pyinstaller
then write this command;
pyinstaller --onefile -w your_file.py
--onefile will convert all the files in your project into a single file.
-w: command prompt (console) will not pop-up when you will run this .exe file. If your app is a console app, then remove -w.
This will convert your file into an .exe file and will run on any other computer without python installed.
More info at https://youtu.be/UZX5kH72Yx4.

How to install pyinstaller (windows) [duplicate]

This question already has answers here:
How to install PyInstaller? [closed]
(3 answers)
Closed 2 years ago.
I want to convert .py files to .exe files so I can execute them on a webpage. However. every method of doing this involves pyinstaller which I do not know how to install. Could someone either explain the procedure to get pyinstaller OR tell me if there are any other methods to convert .py to .exe without using pyinstaller
Installing Pyinstaller
Installing pyinstaller is pretty simple and straight forward. All you gotta do is pip install pyinstaller or python -m pip install pyinstaller (obviously you have to make sure that your python and pip are in PATH).To check if pyinstaller got installed correctly, simply type pyinstaller in your cmd, if no errors appear, it means, you have pyinstaller installed. If for some reason, pyinstaller installs correctly but still doesn't work, you might want to add it in your PATH. You can consider adding C:\Users\user_name\AppData\Roaming\Python\Python37\Scripts to the Path.
Using Pyinstaller
To convert the .py file into a .exe file, you can run the following commands (Make sure you are in the same directory as your python file) -
pyinstaller file_name.py - Simply converts your python file into an executable. This will create a few folders and files, and when you will run your .exe file, it will open up console and run your script.
pyinstaller -w file_name.py - By adding a -w, console will no longer appear while running your .exe.
pyinstaller -F file_name.py - By adding a -F, only one folder will be created, which will be containing your .exe and no other files.
pyinstaller -i icon.ico filename.py - By adding a -i, you will be able to add a .ico file as your icon.
And of course you can use flags in combination to achieve even better results.
[External Links]
Using pyinstaller - https://pyinstaller.readthedocs.io/en/stable/usage.html#options
Installing pyinstaller - https://pyinstaller.readthedocs.io/en/stable/installation.html#installing-in-windows
Working of pyinstaller - https://pyinstaller.readthedocs.io/en/stable/operating-mode.html

Im trying to turn a python file into an exe file and its not working

I tried making my python file into an exe using pyinstaller main.py --onefile --noconsole
.I was getting an error when I tried opening the exe from dist so i used --debug=all and it said pyinstaller: error: the following arguments are required: scriptname.
What exactly do i do im not too sure as its my first time.
To convert a python file to exe:
Make sure you have pyinstaller installed and up to date
pip install pyinstaller
in PowerShell type the following:
pyinstaller --onefile -w 'youfilename.py'
The file name should come out as 1.exe
Make sure are in the right directory
If you have more doubts use this link: https://www.geeksforgeeks.org/convert-python-script-to-exe-file/

Sending a PyCharm project to someone

I just finished working on a PyCharm project (using python 3.7), which uses libraries downloaded using PyCharm's built in functionality. I just want to send this project to my boss so that he can simply run it by clicking on it, without having to go through downloading PyCharm and downloading the applicable packages. Please tell me that there is a way to do this. Thank you
if you want to convert your python project to a program exucutable in windows you can use the library pyinstaller.
install the library:
pip install pyinstaller
then in the path of the project,open a command console and type the following commands.
if you want the executable in one file(slower start):
pyinstaller.exe --onefile --windowed --icon="your_icon_file".ico "your_python_script".py
if you want the executable in one folder(faster start):
pyinstaller.exe --onedir --windowed --icon="your_icon_file".ico "your_python_script".py
this wil create a folder call "dist" where your .exe will be,
pd: whith the --onedir command you will see all your dependencies in that folder, if you have a simple script you can use the first option.
Link to the pyinstaller documentation:https://pypi.org/project/pyinstaller/
You could solve this issue by converting the .py file to an executable file or .exe file....
Hopefully it helped..thx
A simple way to that would be sharing it on github with a requirements.txt file containing all the dependencies which then can be installed using python -m pip install -r requirements.txt.
Or You can use pyinstaller --onefile <yourfile.py> to create a .exe file which could be run without any requirements on windows.

Categories