Pyinstaller - Error loading Python DLL - FormatMessageW failed - python

I compiled my .py file running following commands:
pyinstaller myfile.py --onefile.
When i run it on my pc(Windows 10) everything works just fine.
When i try to run it on my `virtual machine(Windows 8).
I get the following error:
Error loading Python DLL
'C:\Users\MyUsername\Appdata\Local\Temp\NUMBERS\python36.dll'
LoadLibrary: PyInstaller: FormatMessageW failed.
I already googled the error and i found many solutions but none of them worked..
//UPDATE:
If i compile it with my virtual machine, everything runs fine on the virtual machine, main pc and even on my windows server.. strange.. so it must be a problem with my main pc.
Kind Regards

I had a similar problem trying to run a python-based program (aws cli) and getting the "Error loading Python DLL ... LoadLibrary: The specified module could not be found." on Windows Server 2008 R2.
I solved this issue by installing the Visual C++ Redistributable for Visual Studio 2015 run-time components. https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145
Hope it helps!

You can use auto-py-to-exe instead:
python -m pip install auto-py-to-exe
And then wait for it to download and then write in then cmd (or terminal):
auto-py-to-exe
A screen will appear:
And just make as I made in the screenshot, then press "convert .py to .exe" and then press "show output folder".

This also happens when you read the .exe file located in build.
You need to run the exe located in dist folder.
If the error persists even on dist folder .exe , check the exact version of python, download python dll from internet for that exact version, in keep in the folder suggested by the error message (path where this dll is missing).

Try to download a 32 bit version of python36.dll (or 64 if you tried 32)
That fixed the problem for me

Related

Pyinstaller: OSError: Cannot load AutoItX from path

So I have a program and whenever I start it from the command line it works totally fine. What I need now is an Executable and therefor I tried to do it with pyinstaller, which analyzes normally automatically which modules have been imported and it works fine with all of the modules except for autoit. The way I import it looks like that:
import autoit
So I tried to make an executable by following command:
pyinstaller --onefile ./rocketupload.py
Which gave me this Error (Excuse me, that I have to make a screenshot, but the window was open for a second and closed immediately afterwards, so I was not able to copy and paste it here):
I was able to create a functioning exe by copying the autoit dll to the path mentioned in the Error, but that is just a temporary solution, since I want the executable to be running not only on my PC.
I've also tried this one without succes:
pyinstaller --hidden-import=autoit --onefile --paths c:\users\semjo\appdata\local\programs\python\python37\lib\site-packages\autoit\lib .\rocketupload.py
So the problem here is that the autoit module does not get copied from pyinstaller so It cannot run the executable as inteded. But I dont know how to solve it, so that the exe can run as intended. Hope you can help me here, tried to find a solution for hours now...
I had also encountered the same problem and i solved it by implementing the follows:-
Re-installed the pyinstaller module using the latest installer available in github i.e. pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
Re-created the executable package by running the command i.e. pyinstaller --hidden-import=selenium --hidden-import=autoit your [python_file.py]
Copied the installed module i.e. autoit's folder from my PC's directory (C:\Users\\AppData\Local\Programs\Python\Python37\Lib\site-packages) and pasted it inside the [python_file] folder in dist folder which was generated by pyinstaller.
To test the solution, i re-run the generated .exe file in command prompt. Hope this help.
hiddenimports = [ "autoit.init", "autoit.autoit", "autoit.control",
"autoit.process", "autoit.win" ]
datas = [
[
"C:\\Python27\\lib\\site-packages\\autoit\\lib\\AutoItX3_x64.dll",
"autoit\\lib"
]
]
https://raveendran.wordpress.com/2012/06/15/how-to-installregister-autoitx3-dll/
Do this two process your issue will resolve. It resolved me.

Python executable created using pyinstaller will no longer run with dependant packages

I have a program written in python that is exported to a raspberry pi to run. I tested the .py file in the raspberry pi to verify that it works, then used pyinstaller to make a --onefile copy of the .py file as an executable. When I attempt to run the executable, I get an error that states no module named tkinter.
ImportError: no module named tkinter
I had problems before using pyinstaller on an x86 computer and trying to port to the raspi, but I compiled on the raspi and avoided that issue, now it just seems like I am not freezing all the packages like it is supposed to. To make the executable, I ran the following:
pyinstaller --onefile bar_3axis.py
Any help would be appreciated. Do I need to post complete readout from pyinstaller command?
Well I would like everyone to know it was because my program was written in and supported by python3 packages and I downloaded and was using pyinstaller that used python 2.7 to make the executable. I uninstalled pyinstaller and redownloaded using pip3 and it worked like a charm.

Convertin .py files to .exe and run it in windows 10 without any installation

I have already converted my python script .py to .exe using pyinstaller. When I try to run this exe in Windows 10. It states this app can not be run on your PC.
As far as I see, I need to install Python in Windows as well, but in my situation this is not an option. In my company, every computer uses Windows 10 and there is no way for me to install Python all of them.
What I wonder is that whether there is any way to run my .py script in Windows 10 without installing anything into Windows 10. I should give a working directory to people in my company and they should run my script with just one click.
EDIT:
With the help of #Amey and #L00n3y, I managed to solve my problem. In case anyone has same problem, I explained the procedure clearly, in this link.
have you tried py2exe?
py2exe is a distutils extension which allows to build standalone Windows executable programs from Python scripts.
You can download it here:
https://pypi.org/project/py2exe/
You can also use 'Pyinstaller' which is widely used.
Install it using,
pip install pyinstaller
And create an executable using the following command,
Python pyinstaller.py --onefile pythonfile.py
With the help of #Amey and #L00n3y, I managed to solve my problem. In case anyone has same problem, I explained the procedure clearly, in this link.

Any way to compile Python 3.4 program to exe? Except py2exe, pyinstaller or cx-freeze

I have coded selenium Python script and now I want to compile it to exe file so it can run on computer without Python installed
I've tried to install cx-freeze and pyinstaller but failed to do so and wasn't able to find the patch for the errors I am getting while installing these modules
I have installed py2exe but its not able to convert selenium Python to exe
Whenever I execute I keep getting error msg
I want to use chromedriver, here's the error I am getting
FileNotFoundError: [Errno 2] No such file or directory: 'selenium\\webdriver\\re
mote\\getAttribute.js'
You have to manually copy the selenium folder in the root of your project, (this is what the message says) because it include contents that can't be compiled (such as getAttribute.js)

py2exe failed to load specified module

I compiled a simple python module using py2exe. It works fine for me when I run the executable through the cmd window, but when I give it to someone without Python installed, they get the following error message:
LoadLibrary(pythondll) failedThe specified module could not be found. C:\PYTHON27.DLL
How do I resolve this issue?
Py2exe doesn't actually create one single executable. You have to include the dlls and other files in the folder.

Categories