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!
I am trying to package my python file using Pyinstaller. I follow the instructions from this link
https://datatofish.com/executable-pyinstaller/
but I get this error.
RecursionError: maximum recursion depth exceeded.
I tried to added the following line of code as it was suggested on few pages but so far no success.
**import sys
sys.setrecursionlimit(1500).**
Any help?
Just so you all know the error was caused by Anaconda environment. It is not compatible with Python 3.7 and Pyinstaller. As soon I as uninstall Anaconda and run the Pyinstaller function, everything was fine and I managed to create an exe file.
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.
I am running Python 3.5.1 and PyInstaller 3.2 on Windows.
I need to compile my script into an exe. I have done this with pyintaller before with different scripts and have had no issues. Pyinstaller is having trouble importing xlrd. I have tried:
--hidden-import=xlrd
and also
--hidden-import xlrd and neither has worked.
I have heard about hooks but I cannot find any documentation on how to set up the hook-xlrd.py file.
I have been getting the error:
ImportError: No Module called xlwt
The script runs perfectly from the Command Prompt.
Somehow, your application requires xlwt. So do a pip install xlwt and then add --hidden-import=xlwt to your arguments. For a more comprehensive guide, see here.
I'm making a program using Python2.7 and Kivy1.9.2-dev, and trying to package it with PyInstaller-3.0 for different systems as a single executable.
The systems I'm trying to package it for are these:
64-bit Linux Mint 17.3
32-bit Linux Mint 17 (also tried while upgrading to 17.1 and 17.3)
32-bit Windows XP SP3
Raspbian (Raspberry Pi)
On all these systems the program is working well when just run with Python, uncompiled. (so, all Kivy dependencies are fine, too).
However, out of the executables made with PyInstaller, only the one made on 64-bit Linux works as one file. The Windows and Raspbian executables mostly work (I'll write about it later), but the one made on 32-bit Linux still doesn't run. It gives the following error when run (I tried running it on both 32 and 64-bit Linux):
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "/media/Data/Programming/Python/installers/PyInstaller-3.0/PyInstaller/loader/pyimod03_importers.py", line 363, in load_module
exec(bytecode, module.__dict__)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 48, in <module>
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/extern/__init__.py", line 60, in load_module
ImportError: The 'six' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
pyi_rth_pkgres returned -1
Here's what I'm confused about:
Inside my "/usr/local/lib/python2.7/dist-packages/" there is no "pkg_resources" folder, but the above indicates that it, apparently, is there... It even reads the files there successfully. Is it something that gets created just when the executable starts?
I don't specifically use "six" for anything, before this error I didn't even know it existed.
"Six" IS installed on my system, as confirmed by the Package Manager and by Pip. It's located in "/usr/local/lib/python2.7/dist-packages/". I guess PyInstaller can't find it for some reason (as, I believe, if everything is packaged correctly it doesn't have to be there on the system where the executable is run.)
So, my question is pretty typical, what may cause this problem for PyInstaller (just in case, I DID run the "setup.py install" for it), and how to get around/fix it?
Thanks!
PS: On a side note, I mentioned the problems with Windows and Raspbian executables. On Windows, the exe only runs when there is "zlib1.dll" present in the same folder (even if specifically packaged into the exe with PyInstaller, it doesn't work), and on Raspbian I only got the program working without using "--onefile" (with "--onefile", it seems PyInstaller doesn't package any Python binaries into the executable, like libpython.2.7.so, and maybe others too)
Well, adding 'six' into hidden packages, as Clement suggested, didn't work, but started a sequence of trial-and-error that finally led to a solution.
After the test with "hiddenimports" didn't work I tried just importing 'six' into my Python code. And the compiled executable no longer showed this error! However, it now said that the package named 'packaging' is required... Which I didn't have installed.
To put it short, starting from the initial problem, I did this:
Installed 'packaging' using 'pip':
sudo pip install packaging
Added these imports into my main Python code:
import six
import packaging
import packaging.version
import packaging.specifiers
(all the imports added were trial-and-error, done until the PyInstaller-made executable finally worked).
Seems a bit hack-y, as making the executable for a 64-bit Linux didn't require any of these imports, but at least it now works, and the executable size is basically unaffected.
For the following setup (anaconda):
PyInstaller: 3.2
Python: 3.5.2
Platform: Windows-10-10.0.10240-SP0
Numpy: 1.11.1
And the following mwe.py:
import numpy
print ("hello world")
I had to do the following to fix:
pip install packaging
Build with the following bat file (^ is the BAT line continuation):
pyinstaller --noconfirm ^
--hidden-import six ^
--hidden-import packaging ^
--hidden-import packaging.version ^
--hidden-import packaging.specifiers ^
--hidden-import packaging.requirements ^
mwe.py
I had a similar problem. Try to add "six" as well as "kivy" to the hidden_packages in your spec file. If it doesn't work, make sure that setuptools is installed in its 19.2 version. It seemed to be the problem for me on Windows. Hope it helps.