Executable PyQt5 desktop apps - python

I am creating a desktop app with PyQt5 then making it executable with the pyinstaller, but I want to create an installation so that when I share just an exe file, people can first install dependencies, then run the app. Pyinstaller creates dist and builds folders on my PC, and I want this app to create these required folders on the other computer when exe file is used; what I want to do is make the app have a set-up so that all the dependencies will be installed for others. I searched on the internet but couldn't find a way to do it.

You can use pyinstaller with following command
pyinstaller --onefile --windowed myscript.py
this will create single exe file in dist folder
see this for more info
https://pyinstaller.org/en/stable/operating-mode.html#bundling-to-one-folder

I found this, it uses InstallForge to create a setup for the app. If you have better options, it would be better to know

Related

How to convert tkinter script which uses multiple image resources to create a single executable

I want to create a single executable from my Python project which uses tkinter. A user should be able to download and run it without needing Python installed. What can I use to build a self-contained executable from a Python project?
my question is somewhat similar to this one but I didn't find what I was looking for there.
I have a folder which looks like this:
-project/
-script.py
-res/
-image1.jpg
-image2.jpg
-image3.jpg
In my script.py I am using the images from the res folder in my tkinter UI and I want to create an executable out of this script. what would be the best way to tackle this problem?
You can try using PyInstaller
PyInstaller - How to convert to .exe
1. Installation
The pyinstaller module makes you able to create a standalone exe file for pc from a python script, so that you can use it on other computers than do not have python or your python version.
To install pyinstaller: pip install
2. Create an exe
After you installed pyinstaller, go in the folder where your python script to be transformed in exe is and type in the command line (go in the address bar on top of the window and type cmd). Then type :
pyinstaller yourscript.py
where your script is the name of your file.
You will find a folder called “dist” where there is a folder called yourscript (if the name of your script was this) where there are many files and the exe file that will allow you to run the script also on other computer. You just have to copy the whole folder.
3. What to do if there are images
If you use images, that are in the same folder, for example, you can copy manually into the folder made by pyinstaller or you can run this command to make it do it for you:
pyinstaller –add-data “*.png;.” yourscript.py
This way you will see that in the folder where your exe is there are also the png files (all of them, if you want just one do not put the asterisc, but the whole name of the file.
External links - PyInstaller
Use a bundler like Pyinstaller.
Pyinstaller website
Include images in Pyinstaller
Note: If you are having issues with tkinter and pyinstaller take a look at this: Problems with Pyinstaller with tkinter app on python 3.5

How to run pyinstaller from python script already converted to exe?

I'm trying to run pyinstaller in python exe file in order to someone without python can use pyinstaller but no idea how to do it.
I tried import PyInstaller with other needed modules and convert this script to exe but I got error "The 'PyInstaller' distribution was not found and is required by the application". I also tried to pack PyInstaller exe file but didn't worked too. Python 3.6.5
Any ideas how to do it?
Unfortunately, what you're describing is not possible with PyInstaller. I submitted an issue on GitHub, and this is what one of the developers said:
Nope, this won't work.
PyInstaller internally uses a lot of sub-processes where it is assumed that sys.executable points to a python interpreter (e.g., here); this is not true in a frozen application, where it points to the frozen executable, which ends up in effectively endless recursion.
Even if this was not a problem, the frozen application includes only a subset of python environment, so it cannot be used to freeze an arbitrary script (not to mention the issue of 3rd party packages).
So whatever use case you have for this, it cannot be supported by PyInstaller.
check the requirements for the Pyinstaller from this link initially
https://pythonhosted.org/PyInstaller/requirements.html
Then install Pyinstaller by,
pip install pyinstaller
To create .exe file use this command for basically,
pyinstaller your_script.py
To run the created .exe
METHOD 1
Do double click the .exe file in your directory.
METHOD 2
In your cmd prompt load in to your current directory or project directory then do
: .\dist\your_script.exe
because the create .exe files are saved in dist folder inside to the project folder with the name of your script file names only.

.py to exe without other files

Using pyinstaller, I created a .exe file and other files. Can I create ONLY the .exe, without other files, or is there any way to put together all files? I need your help.
Run this command;
pyinstaller --onefile your_script_name.py
If you are a learner, you will get good insight into how to create an exe file using PyInstaller. I provide below the github link for a very small project. You will be able to create exe using the following command.
setup.py clean develop install
Github Link : https://github.com/debjava/py-exe-creator1
First you download the project and run the above command just to see the exe.
As per the above project, you can similarly put all your project file and you can use the same command to run to create exe file using pyinstaller.

Pyinstaller - convert python to exe from Linux

I want to convert one .py file to .exe from Linux Ubuntu. I found pyinstaller for this. But when pyinstaller runs from Linux it makes file executable only for Linux and when pyinstaller runs from Windows it makes .exe file for Windows. I want to convert .exe file from Linux for Windows. So how can i make it? I need an instruction.
P.S: if i cannot do it with pyinstaller, please write other tool.
If you know how to use Docker, that may be an easy enough way to do it. The relevant docker images can be found here.
From the documentation there:
There are two containers, one for Linux and one for Windows builds.
The Windows builder runs Wine inside Ubuntu to emulate Windows in
Docker.
To build your application, you need to mount your source code into the
/src/ volume.
The source code directory should have your .spec file that PyInstaller
generates. If you don't have one, you'll need to run PyInstaller once
locally to generate it.
If the src folder has a requirements.txt file, the packages will be
installed into the environment before PyInstaller runs.
For example, in the folder that has your source code, .spec file and
requirements.txt:
docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows
will build your
PyInstaller project into dist/windows/. The .exe file will have the
same name as your .spec file.
docker run -v "$(pwd):/src/" cdrx/pyinstaller-linux
will build your PyInstaller project into dist/linux/. The binary will have the same
name as your .spec file.

Pick up directory with pyinstaller

I have made a small programm with Python 3 and Qt-Designer using Pyqt5.
the programm should open a pdf file which is located on a directory on my pc and another exe file, which is also on my pc.
I'm using in the code:
os.startfile("D:\Python_files\MA\Programm\K_file\dist\K_D\K_D.exe")
os.startfile("D:\Python_files\MA\Programm\Help.pdf")
then I used pyinstaller to make it standalone app. The problem is that pyinstaller does not pick up those two file (pdf and exe). So when somebodyelse download the app on thier pc, it wont work because the pdf and the exe are missing.
How to fix this?
I'm using this command in pyinstaller
pyinstaller --onefile --icon="if_icon_64682.ico" --clean ProgV_1_6_Final.py

Categories

Resources