FatalError failed to execute script. PyQt5 - python-3.x

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.

Related

import error with youtube_dl after compilation with pyinstaller

So I recently embedded youtube_dl into my python 3 project which all works very nicely.
The problem occurs when I compile that into an exe file using:
c:/python332/scripts/pyinstaller myprogram.py
It compiles fine, but upon running the exe I get an error similar to this:
Runtime Error!
Program: C:\python332\python.exe
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
This specific error occurs if I go to the directory on command line, enter py -3 then try to import youtube_dl.
Interestingly, if I go to a different directory and then run py -3 and import youtube_dl it works perfectly fine (if the load time is a whee bit slow).
As extra information, for some reason pyinstaller is including both python27.dll and python37.dll, when I would have thought it would only want python37.dll?
Looking in the dist folder of the program I can see that a msvcr90.dll is present.
I am wondering is this some sort of compilation clash where pyinstaller is mixing python 2 and python 3 together?
Is there a known fix for this?
thanks.

Getting error when using pynput with pyinstaller

A friend of mine asked me to write him a program, and I used pynput to handle some of the inputs and other features. When I convert the program an executable with pyinstaller, launcing the executable gives me this error: File "site-packages\pynput\keyboard\__init__.py", line 31, in <module> File "site-packages\pynput\_util\__init__.py", line 82, in backend ImportError [11492] Failed to execute script friend_project
I have tried using the pyinstaller command pyinstaller --onefile friend_project.py, and also using auto-py-to-exe to run it.
Using pyinstaller with other modules like pygame or pyopengl gives me no error, but this one module does.
Running the script by it self with the python inturpeter works fine, but I would perfer to have it be an exe so I can give it to him with out him needing python to run it.
Please fall back to 1.6.8 version of pynput.
pip install pynput==1.6.8
If you are running Windows you need to add these parameters to the command line (for the first time, after that they will be included in the generated spec file).
--hidden-import "pynput.keyboard._win32" --hidden-import "pynput.mouse._win32"
For Linux, use:
--hidden-import "pynput.keyboard._xorg" --hidden-import "pynput.mouse._xorg"
More information can be found in this Github issue.

Pyinstaller : Kivy: AttributeError: 'NoneType' object has no attribute 'clearcolor'

I am trying to package a kivy based python application for windows using auto-py-to-exe. auto-py-to-exe uses Pyinstaller for packaging. So after packaging the application and trying to run the created executable file of the application, I encounter this error:
File "desktop.py", line 356, in <module>
AttributeError: 'NoneType' object has no attribute 'clearcolor'
which in the actual code in desktop.py refers to:
from kivy.core.window import Window
....something....
if __name__ == "__main__":
.... something
Window.clearcolor = (1, 1, 0.99, 1)
....something
Here I am trying to provide close to white color background to the window.
I have checked for proper installation of kivy and availability of kivy.core.window module in site-packages of python.
I have read at severals places to use the package-name in --hidden-import as sometimes modules may not be picked due incorrect path or other issues, so I have tried passing this module as --hidden-import "kivy.core.window" and also tried --add-data flag as --add-data "C:/Python3/Lib/site-packages/kivy/core/window;window/" to forcefully include kivy.core.window.
However no luck and I still getting the same error.
If I am not mistaken the above mentioned error means the code get Nonetype when it tries to access window although the module is present at right place i.e. after packaging it is present in the package along with other kivy modules.
Also when I run the script from some IDE it works fine.
I have followed this document for debugging the Pyinstaller warnings/errors.
Config: Windows10, Python3.4, kivy 1.11.1
What am I missing or how can I specify executable to look for the file at the correct path?
So after #inclement's comment : to remove the line
After removing this line I get [CRITICAL] [App ] Unable to get a Window, abort. . I have browsed this error and found different solution referring to sdl2.dll here. So I went ahead and added path to .dll files for sdl2, glew and angle in Windows environment variable path PATH = C:\Python3\share\sdl2\bin and so on for glew and angle. So all the .dll files are imported properly and it works fine.
I use this way to solve it:
(If you don't want to find sdl2 bin path, you can use this way.)
pip install pygame
If you use custom spec, you will need to edit it to let pyinstaller rebuild exe.
I don't know how does it work, but it work for me.
(Pygame also use sdl2)
(My env: kivy 2.1.0, pyinstaller 5.1, conda env, python 3.7)
Or like answer above, but use some different way:
# In spec file, modify this line:
a = Analysis(
...
binaries=[(r"Your_env_path\share\sdl2\bin\*.dll", ".")],
...
)
You can also use --add-binary argument.
how to use bundled program after pyinstaller --add-binary?
# In Unix
pyinstaller -w --add-binary="Your_env_path\share\sdl2\bin\*.dll:." -F main.py
# In Window
pyinstaller -w --add-binary="Your_env_path\share\sdl2\bin\*.dll;." -F main.py
Or following official way:
https://kivy.org/doc/stable/guide/packaging-windows.html
"Editor and add these lines at the beginning of the spec"
# In spec file:
from kivy_deps import sdl2, glew
exe = EXE(
...
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
...
)
My english is not good, hoping this conveys the correct meaning.

TkDnd working in Spyder but gives error after converting .exe

I am creating one application which sorts files and merges them based filename. I needed filepaths when i drop files from file browser to my widget's listbox. For Tkinter i installed TkDnd. I followed instructions from How to Install and Use TkDnD with Python 2.7 Tkinter on OSX? and it worked for me. I am using Anaconda and i paced folders in C:\Users\Anaconda3\tcl and C:\Users\Anaconda3\Lib\site-packages. I am using Spyder and python 3.7. I made executable from below command:
pyinstaller --onefile -w PDF_Merger.py
After opening file it gives me error:
Fatal error ".py failed to execute"
I know this problem is regarding linking TkDnd.
I have tried making executable with --onedir and it still gives me error. But after copying tkdnd2.8 to dist it works.
Here is my code using TkDnd:
from TkinterDnD2 import *
widget = TkinterDnD.Tk()
filesinfileslist = Variable(widget)
FilesShow = ReorderableListbox(widget, font=('aerial',12), height = 23 , width = 45, listvariable = filesinfileslist, selectmode = EXTENDED)
FilesShow.place(x=10, y=40)
FilesShow.drop_target_register(DND_FILES)
FilesShow.dnd_bind('<<Drop>>', drop)
drop method takes only pdf files and sets it to listBox.
As of now it works in spyder but .exe file gives me error. Can anyone show me how to resolve this issue or if i made some errors in code?
I resolved this issue with adding files from tkdnd2.8 folder with --add-data attribute while generating executable with pyinstaller. I was able to create it with onefile.
This post is already a few years old but I got to it when I looked for my problem. In the end I solved it like this:
pyinstaller --onefile --add-data=C:\ProgramData\Anaconda3\tcl\tkdnd2.8\;' myfile.py

Python 3.6 cx_freeze ModuleNotFoundError: No module named Tkinter

I froze a python 3.6 program with cx_freeze, and it worked just fine. But as soon as I tried to run it, I got this error message.
Does anyone know what to do? Please help!
try using
import tkinter
(small 't' instead of capital)
Try checking the dir names in the 'lib' folder (in my case it was 'build\exe.win-amd64-3.6\lib'). I had a similar issue (without the 'ImportError: DLL load failed...') and found that the 'lib' directory contained a "Tkinter" folder. Changing its name to lowercase 'tkinter' did the trick and made the .exe run just fine.
If you read the error more clearly, it stated in a comment that if importing _tkinter failed, your computer isn't configured to use tkinter. You should download tk and ttk to make it work.
And According to http://wiki.python.org/moin/TkInter :
If it fails with "No module named _tkinter" or "Tkinter", your Python configuration
needs to be modified to include this module (which is an extension
module implemented in C). Do not edit Modules/Setup (it is out of
date). You may have to install Tcl and Tk (when using RPM, install the
-devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in
the default locations, simply rerunning "make" should build the
_tkinter extension.

Resources