Executable made with pyInstaller/UPX experiences DLL load failed: The parameter is incorrect - python-3.x

Executable made with pyInstaller / UPX in virtual environment throws an error
DLL load failed: The parameter is incorrect. while parameter is correct...
I've made python Executable withoutpyInstaller UPX Its about 250MB & Its working Fine.
To reduce size I've created another python Executable (Contains Same Code) Using pyInstaller UPX and its gives me an error refer Error_img.
Code Contains libraries like Pandas,Numpy,Openpyxl
The error is showing at line 8 where I've defined Pandas library

I came up with the solution and It's working perfectly Fine...
Need to add Pandas and Numpy Manually using pyinstaller --add-data option
pyinstaller --add-data C:\ve\mypython\Lib\site-packages\pandas;pandas --add-data C:\ve\mypython\Lib\site-packages\numpy;numpy --icon=icon_file.ico --version-file version.txt --noconsole --upx-dir=C:\upx --upx-exclude vcruntime140.dll --upx-exclude ucrtbase.dll --onefile Foo.py
After creating Executable the size of an EXE is 170MB.

Related

How to freeze my Python code with PyInstaller when the exe says it miss some files?

I am using Python 3.7.9 with Pyinstaller 5.0.1
I am trying to freeze my code which uses pyshadow.
When I execute it from Pycharm it works fine.
When I execute the exe after I freezed the code, I get this error:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\gauth\\AppData\\Local\\Temp\\_MEI233082\\pyshadow\\resources\\querySelector.js
This could be a common issue when your python code uses some specific module that needs some third files. In my case, it is about pyshadow missing a JS file.
So I add this file 'querySelector.js' in the freezing command:
pyinstaller --onefile -F --uac-admin --icon="icon_PhoneBot_256.ico" --clean --noconsole --add-data "querySelector.js;." main.py
But I still get the same error.
Does anyone have any idea how to fix this issue?
Thanks to rokm. I get his help from the git forum of the PyInstaller developer (full details here: https://github.com/pyinstaller/pyinstaller/discussions/6905). I publish his answer here in case someone has the same issue.
I had to add the parameter:
--collect-data pyshadow
So my final command is:
pyinstaller --onefile -F --uac-admin --icon="icon_PhoneBot_256.ico" --clean --noconsole --collect-data pyshadow main.py
ANd it works like a charm!

No module named 'reportlab.graphics.barcode.code128' error when using xhtml2pdf

My code works fine when running from the terminal, but when I try to run it as an executable after compiling it, it gives me a No module named 'reportlab.graphics.barcode.code128' error. I tried uninstalling and installing it again but still outputs the same error. Any ideas?
I had the exact same issue. The code works perfectly fine. But when built and compiled, the executable doesn't work. The cause of the error is xhtml2pdf dynamically loading reportlab.graphics.barcode. The solution is to include the entire reportlab.graphics.barcode when building the executable.
In PyInstaller this can be done with:
pyinstaller --onefile --noconsole --collect-all reportlab.graphics.barcode script.py
In nuitka:
nuitka --onefile --windows-disable-console --include-package=reportlab.graphics.barcode --include-data-dir=path_to_reportlab\graphics\barcode=barcode script.py

How to include files while compiling?

I am using pyinstaller to compile a python script to an exe, but before I do that I want to obfuscate it using pyarmor, I fired up pyarmor web ui using pyarmor-webui and created a build that gives out a file named the same one as the file I want to compile but obfuscated and a folder containing two files __init__.py and _pytransform.dll now when I try to compile the obfuscated code into an exe using pyinstaller --onefile myfile.py I get an executable that when I run from a batchfile to look at the output it throws the following error Could not find "C:\Users\0000\AppData\Local\Temp\_MEI72482\pytransform\platforms\windows\x86_64\_pytransform.dll"
myfile.py
import os
import random
for i in range (10):
print (random.randrange(1,100))
Batch file
try_01.exe
pause
How and what do I need to add to pyinstaller command so that it includes the .dll file in the compilation process
The pyinstaller docs say the following:
--add-binary <SRC;DEST or SRC:DEST>
Additional binary files to be added to the executable. See the --add-data option for more details. This option can be used multiple times.
I haven't used pyarmor+pyinstaller before but it should be as simple as:
pyinstaller --onefile myfile.py --add-binary _pytransform.dll
Or, since I looked more into pyarmor's output, it may be:
pyinstaller --onefile myfile.py _pytransform.dll

"Error loading Python lib" when trying to run a python script as an executable

I am hoping to turn my python3 script into a distributable application but I'm having trouble turning the script into an executable.
I've tried using
pyinstaller myscript.py
and
pyinstaller --onefile myscript.py
to create the .exe file, however both times I've tried the .exe after it has been created, it's produced this error or a very similar error:
[4129] Error loading Python lib
'/var/folders/c9/r16n40jd14d9x5f__gb0p3t80000gp/T/_MEIyzoWbA/Python':
dlopen:
dlopen(/var/folders/c9/r16n40jd14d9x5f__gb0p3t80000gp/T/_MEIyzoWbA/Python,
10): no suitable image found. Did find:
/var/folders/c9/r16n40jd14d9x5f__gb0p3t80000gp/T/_MEIyzoWbA/Python:
code signature invalid for
'/var/folders/c9/r16n40jd14d9x5f__gb0p3t80000gp/T/_MEIyzoWbA/Python'
The script I'm trying to run doesn't involve any images but it uses selenium webdriver, I'm very new to python so I don't know if either of these things would be a problem.
I have also tried uninstalling python3.8 and installing python3.7.9 but this has not worked either.

FatalError failed to execute script. PyQt5

I know that questions have already been raised on this topic, but I believe that all decisions were strictly individual. The essence of the problem:
There is a calculator.py script and a kalkulator.py These files are in the same directory, the calculator file is executable, this is the file that I convert into an EXE using PyInstaller. Inside the file, I import several PyQt5 libraries, and the second file is Python: from kalkulator import *
The second file kalkulator.py contains the GUI of the program created with QtDesigner
When i run the command pyinstaller --onefile --debug calculator.py everything goes fine.
But when I run the EXE program file in debug mode, I see the following error:
The photo shows that the following error occurs.
"DLL Load Failed: The specified procedure could not be found."
I can assume that the problem is that when assembling, PyInstaller does not see the file kalkulator.py it contains a graphical interface.
What can you say about this problem, how do you think you can solve it?
I use:
Python 3.5
PyQt5
PyInstaller 3.3.1
I managed to solve my problem! I changed the version of Python 3.5.0 to 3.6.0, and also reinstalled PyQt5.

Resources