Pyinstaller .exe unpacks to ...\local\Temp but then cannot find python37.dll - python-3.x

I'm using pyinstaller v4.0 to create a --onefile for execution on Win 7 and Win 10 machines. Win 7 machines can be either 32 or 64 bit. The ONLY version of python installed on the machine I'm using to build the .exe (run pyinstaller on) is Python v3.7.9 32 bit.
To create the .exe I'm simply using:
pyinstaller --onefile scriptname.py
I copy the resulting .exe from the pyinstaller dist folder to both Win 7 and Win 10 machines and, in most cases, it runs just fine; but on 3 separate machines when I try to run the .exe it throws this error:
"Error loading Python DLL 'C:\Users\username\AppData\Local\Temp_MEI3dddd\python37.dll'.
LoadLibrary: The specified module could not be found."
Note that 'dddd' referenced above can be differing 4 digits on different machines.
I have confirmed that the directory from the path, "_MEI3dddd", DOES get unpacked to the Temp directory, I've even been able to open the the "_MEI3dddd" directory long enough to see that python37.dll is in there.
I have confirmed permissions on the folders in the path are correct to allow the executing user full access.
Can anyone suggest what I am missing?

I found my fix. To resolve the issue, I spun up a VM with a Win 7 SP1 32 bit OS, installed Python 3.7.9 32 bit and pyinstaller.
From there it was just a matter of building the --onefile on that VM and copying the resulting .exe from the pyinstaller dist folder to the other target machines.

Related

My .py executable or setup file works in my laptop but not in another system

I have created a Python code that uses both selenium and openpyxl, the code works fine locally. I Converted it into a .exe and setup files using pyinstaller and it also runs well, but when I transfer it into another computer running on Windows 10 without Python installed, it shows a Runtime error.

Pyinstaller Application Error on Embedded OS

I am trying to build an executable to run on Windows XP Embedded. The app itself is a GUI application built with python 3.4.3 and PyQT4-4.11.4. I use pyinstaller to build the exe with the command below :
pyinstaller --clean --windowed --onefile install_wizard.py --icon="images\installer.ico" --name "Installer"
I can build and run the exe on with no issues on a Virtualbox running either XP or XP embedded.
I also have a flash disk with a Windows XP Embedded image, I am able to build the executable, but I get an application error when I try to run it.
Any ideas, I've looked through the Pyinstaller docs and haven't seen anything that would give me a clue.
Looks like it might have something to do wih pyinstaller, I did a simple test using py2exe instead, and that seem to work.
But any info on why XPe does not agree with pyinstaller would be great.

Python cross-platform portable script

I am working on a web scraper in Pycharm. The project consists of around 5 python files and 8 dependencies. I have a virtual env setup in the IDE. How do I package the files and dependencies so they can be saved on any platform and executed from the command line? I looked into Pyinstaller, but it looks like Pyinstaller only creates executables for the OS it is running on. So I would need to create 2 executables for windows and linux. And, I am not necessarily looking for an executable, just need to be able package it so anyone can download it and run it easily.

Why is the Python 3 Windows AMD64/EM64T/x64 installer a ".amd64" file?

So I noticed the main download button for Python 3 downloads an executable that runs a wizard that is titled "Python 3 (32 Bit)" so I figured "ahh that's fine I'll just run 32 bit Python on my 64 bit OS" but out of curiosity I stopped the install and went back to the site to find "Windows x86-64 executable installer Windows for AMD64/EM64T/x64 4c9fd65b437ad393532e57f15ce832bc 26260496" and it downloads as "python-3.7.1-amd64.exe"I was just wondering what the heck is going on?
Why is the Python 3 Windows AMD64/EM64T/x64 installer a ".amd64" file?
".amd64" is a file extension for 64 bit binaries. While ".exe" is more common, the Python 3 64-bit installer is probably labeled ".amd64" to specify that it is meant to be run on 64-bit machines.

Pyinstaller missing dll files

I want to create a 32bit executable app from my script to run on Windows 10 with X86 or X64 architectures. I've generated the X64 version of my script and it worked fine. My host machine is X64 but I installed Python X86 version to generate X86 app. Then I generated the executable with Pyinstaller but when I run the executable it throws the following error:
C:\Users\Name\Appdata\local\Temp_MEI51162\VCRUNTIME140.dll is
either not designed to run on Windows or it contains an error...
and in the console I see this error:
Error loading Python DLL
'C:\Users\Name\AppData\Local\Temp_MEI51162\python36.dll'.
LoadLibrary:
I've checked the _MEI51162, both VCRUNTIME140.dll and python36.dll is there but the python36.dll has a size of about 1 MB instead of 3 MB. It doesn't matter if I generate the app as a standalone executable or not and still give me the same error.
It seems that the problem happens when you install both 32bit and 64bit of PyInstaller. And PyInstaller would fail on selecting which version of dependencies are required for the current build. The problem in my situation was VCRUNTIME140.dll. I couldn't find a way to replace the vcruntime140.dll, but I found a workaround by adding the correct file manually to C:\Users\<User>\AppData\Roaming\pyinstaller directory and rebuild with Pyinstaller then It will be replaced with the new one just copied. This will fix the issue temporary and the directory should not be deleted.

Resources