Error loading python37 dll on Windows 7 after Pyinstaller created exe - python

I created an exe file using PyInstaller and it works on my PC with Windows 8.1 and laptop with Windows 10, but on computers with Windows 7 it has error
"error loading python37 dll "
and something about dynamic linked libraries.
EDIT:
Error loading Python DLL 'C:\Users\Dell\Appdata\Local|Temp|_MEI16442\python37.dll'. LoadLibrary: Procedure of initialize dynamic linked library (DLL) failed.
It is translated from Polish
Do you know maybe how can I fix it?
I was reading about static linked dll but I dont know how to do it. I am working on Windows only, I dont know Linux/Mac.

This used to happen to me all the time, and it was always because I tried to run the executable file from the build folder while the one that works is in the dist folder.

I had this same issue while compiling the executable with a Pyinstaller command. To fix it, I added the --noupx option and everything worked fine.

Related

Pyinstaller can't find a module? (error loading Python DLL)

I compiled my program with pyinstaller, and it works fine on my computer, but whenever I ty to run it in another computer (with no python), I get the following error:
Error loading Python DLL
'C:\Users\perez\AppData\Local\Temp\_MEI28162\python310.dll'.
LoadLibrary: Cannot find specified module
What can I do? I'm not allowed to install python on the other computer
Ok, it was not working because I compiled the script with pyinstaller having python 3.10, but Windows 7's maximum python version is 3.8
I had the same problem and it was because I was using the output in build/main instead of dist/main (dist/main.exe in case you used --onefile)
Copy the folder where your Python.exe is located and run this Python.exe

Pyinstaller exe not working on other computer(with other windows ver.)

My platform is Windows 10 and Python 3.9. There is another computer(Windows server 2008R2) without Python. So I'd like to use pyinstaller in my computer and use .exe on the other computer.
I tried simple script print("hello") and used pyinstaller -F myscript.py
.exe works on my computer, but failed on the other computer.
Error
error loading python dll ~ python39.dll
Should I use Python 3.8? Or what should I do?
The problem is that Pyinstaller does not create fully standalone executables, it creates dependencies (E.g. this python39.dll), so this python39.dll should be on the computer which is running this executable. Because python is already installed on your computer, python39.dll is already there and everything works fine. The problem is that machine that you're running this program on probably won't have it.
To fix this there are several solutions:
Install python 3.9 on targets' machine (But in this case you don't need to create an executable)
Include python39.dll with your program
For second solution just create a folder and move your executable into it as well as this python39.dll library. Windows will find it because it's in the same directory where this executable is. You can get this library from c:\Windows\System32 folder (Or where all DLL's are stored on your system) and then just copy it into folder with your executable. After that ship not just executable but this folder with library included.
#Stepan wrote in comments that you can also include this library right in your executable by adding --add-binary "path\to\python39.dll" to your command when compiling. The final command will look like this:
pyinstaller -F --add-binary "c:\Windows\System32\python39.dll" myscript.py
Check if the Python version is compatible with the windows version you are trying to use. I was having this problem with an exe I did using Python 3.10. Did it again with Python 3.7 and it worked.
In such cases it could be a solution to use something like auto-py-to-exe wrap for pyistaller: it knows better which option to set for py converting :)
Also, from my exp, in some cases you should modify yout already normally working from terminal Py code before pyinstaller: for example replace exit() with sys.exit() and so on.

Python EXE run failure due to missing DLL's

Good day, everyone!
I made a python script in my Windows 10 laptop that exports sql data into text file. The script was compiled into an executable file via the pyinstaller python package. The exe runs perfectly on my laptop with no issues. However, when I copy/pasted the directory of the exe files in to another laptop (with Windows 7 OS) and run it, errors occur. So, I tried to install python and all the packages I've installed in my laptop to run the script. Yet, the errors remain. Please check the ss of the errors below.
When I run the exe file this pops up
If I click OK, two pop ups appear with the same content
To tell you the truth, this is my first time writing a python script so I may be missing some important details. Please, do explain to me how I can fix these errors. Thank you in advance!
[UPDATE]
I tried to copy/paste the raw python script (pyw) and compiled it to exe on the Windows 7 laptop itself. The error being shown this time when I run the new exe file is "Failed to execute script transfer_out_exporting". No other details are given.
Problem Solved
First, I copied the raw python file (pyw) and compiled it on the Windows 7 laptop itself. This solved the api-ms-win-core dll and python dll issues. Then, I added the read and write files that the exe uses for some data referencing.
The exe was running after doing those steps. I think I was overthinking the problem when I simply had to look at my script. Make sure to always check your script!
Python 3.9 does not seem to be supported on Windows 7 anymore. At least Python 3.7 works on Windows 7 (I don't know about Python 3.8). So, you could compile the program on e.g. Windows 10 within an (anaconda) environment using Python 3.7 and pyinstaller and the resulting compiled program should work on Windows 7.

Missing .dll files in an executable kivy application (matplotlib)

I created a kivy application that allows plotting some graphics by using matplotlib lib. it worked well, and than i converted it to .exe with cx_freeze, it displayed this error :
Intel MKL FATAL ERROR : Cannot load mkl_intel_thread.dll.
After hours in forums, i putted all the mkl .dll files that exists in the Anaconda3-Windows-x86_64\\Library\bin in Anaconda3-Windows-x86_64\Lib\site-packages\numpy\core folder because matplotlib needs numpy. with this action, the executable works perfectly on my laptop but not for the other users's laptops, it displayed this error :
System Error
The program can't start because mkl_core.dll is missing from your computer. Try reinstalling the
program to fix this problem.
And then i putted the dll files in some folders in the executable's lib folder and now it displays this error :
System Error
The program can't start because libiomp5md.dll is missing from your computer. Try reinstalling the
program to fix this problem
I don't understand whey these errors and how to solve this issue. I know that there is no error in my scripts (myapp.py and setup.py ) because it works well in my laptop.
Have you any idea please ?
Thank you
I am wondering if you properly assigned access permissions to the files. If you put them manually they may get your user's permissions and hence appear to be missing (inaccessible) for any other user.

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

Categories

Resources