Do PyInstaller build artifacts contain Python, package, and PyInstaller version info? - python

I'm using PyInstaller to build a Windows EXE. It's building correctly, but the EXE is almost double the size of an EXE generated from the same .py code in the past. I'm assuming that either the version of Python, an imported package, or Pyinstaller itself has changed. I have the /build directory artifacts and the .spec files from the current and prior builds. Is there a way to extract the version information from those artifacts to figure out what has changed? When PyInstaller runs it prints out its version but I'm not seeing anything like that in the /build directory.

Related

How to remove Bad magic number error in Pyinstaller

I have a python project which contains app.py and source.py files. Project also has other files for configs and logs. I have converted app.py to app.exe using pyinstaller
pyinstaller app.py
This has created a dist directory. I have copy pasted source.py, configs and the log files in the dist directory.
I also want to create a setup for this which will be installed on another machine. I cannot share the source.py file as it is thus instead of .py I have used source.pyc. I have now used inno compiler and have created a setup file.
As per my understanding, pyinstaller automatically binds the python interpreter so we do not need to install python on any other machine. I simply installed the exe and it started working fine.
In my project, I have a functionality which calls the source.pyc file like below:
exec(os.system("source.pyc install"))
This was working fine on my development machine but in other machine, it is giving me bad magic error.
As per online forums, this normally happens when we try to run the pyc file with different python version interpreter but in my case I am using the same pyinstaller interpreter. Then how come this error is coming.
Is there any other of compiling the additional files apart from app.py using pyinstaller. How can I remove this error. Thanks
PyInstaller does not bundle or bind a Python interpreter with the EXE file. The EXE file is a compiled binary file which, as it is compiled, does not need an interpreter. A PYC file still requires an interpreter.
You can compile the other files (i.e. source.py) using PyInstaller as well, and then move the compiled EXE file to the same directory as app.exe. In that case you would be able to run your command of import os; os.system("source.exe") from the main program. If your other compiled scripts require modules/libraries not used/included in the app.exe compilation, then when moving the compiled source.exe, you will need to move the bundled libraries to the app.exe directory as well.

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.

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.

Pyinstaller: WARNING: lib not found

I'm trying create an executable from my code that uses PyQt5. I'm using Python 3.5.3 -64 bits, developing in Windows 10, used pip to install pyinstaller 3.2.1, and installed pywin32. Pyinstaller runs but outputs warnings that libraries aren't found.
I'm creating my application using the following:
pyinstaller Start_UI.py
Which outputs these warnings.
pyinstaller Start_UI.spec
Which outputs these warnings
When I open the executable that pyinstaller creates, the application closes immediately. I suspect the application is failing because of the warnings. How can I resolve the warnings so the executable works?
Thank you for the replies.
Edit:
I searched for DLL files on my computer and copied them into the dist folder which resolved the warnings output by:
pyinstaller Start_UI.py
As for:
pyinstaller Start_UI.spec
I located the mission api-mis-win-crt-* dll files in my installation of Windows SDK, and copied them into dist as well. This time, the warnings were not resolved as pyinstaller can't locate the dll files. Where do I need to put the api dll files for pyinstaller to locate them?
After a lot of research, the problem is because of Windows 10. While I didn't find a Windows 10 solution, I did solve my problem in Windows 7.
I tested pyinstaller on Windows 7 and was still getting warnings, but not the api-ms-win-crt-*.dll warnings.
I copied all the dll files in my Python35 directory into the pyinstaller generated dist folder. At this point, pyinstaller can turn a Hello World program into an executable without errors:
pyinstaller --onefile Hello_World.py
However, turning a PyQt5 program into an executable gives errors because pyinstaller can't locate the Qt5*.dll files. To fix this copy the PyQt5, Qt5*.dll files, under Lib/site-packages/PyQt5/Qt/bin and into dist. Then tell pyinstaller where the dll files are using --path:
pyinstaller --onefile --path dist Start_UI.py
This creates a working executable Start_UI.exe in dist.
Looks like the error was due to vcruntime140.dll not being included in the dist folder. Check the executable after manually copying it to the dist folder

Compiling a non-standard module into an executable file with PyInstaller

Background: I have had success in the past installing and using Pyinstaller to transform my python projects into one-file executables. I don't think it is an issue with my source code or pyinstaller files.
Problem: I used a free, open-source library/module called easygui imported into my source code to build an application. The application works perfectly run natively or through the Python IDE. I am pretty sure the problem is that Pyinstaller is not finding the EasyGUI module to import (it automatically includes and compiles any libraries you import in the script).
Actions: My python folder is not in the C:\ drive, it is in the E:\ drive. I'm able to access the pyinstaller path in "E:\program files\python" but it is not reading the easygui library, I don't think. I installed pyinstaller and easygui using pip.
Reading a LOT of pyinstaller's documentation i tried to run it to include a paths dir like:
E:\Program Files Hard Disk\Python\Scripts>pyinstaller --paths
DIR "E:\Program Files Hard Disk\Python" --onefile "E:\Program Files\Python"
It does output the single executable in the build file but does not launch correctly. From what I can see in the console window the brief moment it's up, it looks like an easygui issue. Here is the result of attempting to launch the executable from the command-line:
Here is the compiling in the command window:
Please help

Categories

Resources