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.
Related
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.
I have created a simple python .exe file and shared it across to people who don't have Python environment on their system. One of my colleagues is getting the below error:
The code execution cannot proceed because python37.dll was not found. Reinstalling the program may fix this problem.
The .exe is created using cx-freeze. Is there any additional configuration I need to do or any alternative method of doing this?
Alternative method: Use pyinstaller to generate an .exe:
scripts/pyinstaller hello.py
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
I am using Python 3.3.3 and I have been trying to build a .exe from a simple .py script.
My script looks like this:
import encodings
print('Test')
and executes correctly.
When I try to build it with PyInstaller with this command:
pyinstaller --onefile Testmodul.py
and try to open my .exe it shows up with this error:
Fatal Python error: Py_Initialize: unable to load the file system codec, ImportError: No module named 'encodings'
I already tried importing the 'encodings' module in my testscript but it is still not working, I have also tried py2exe and it is also not working at all.
Is there anything I do wrong? Do I have to setup something in my PATH? the correct path to "C:\Python33" is included in there already.
EDIT: To everyone with this problem: I gave up, and after a fresh install of windows and python and all the other stuff, I tried it again, the same way as before and it worked without a problem.. It is worth a try if you are really desperate!
This is probably because pyinstaller did not include the module in the first place. Try one of the following solutions.
1) Specify the path to your module during compilation:
pyinstaller --onefile --paths=/path/to/module Testscript.py
2) Specify the path from the .spec file:
run this command first(in pyinstaller's directory):
python Makespec.py --onefile /path/to/yourscript.py
now you have the .spec file. open it in your text editor, and add the path to your modules to the pathex.
pathex=['C:\\path\\to\\module']
then, build your program:
python Build.py /path/to/yourscript.spec
3) Use hidden imports:
pyinstaller --onefile --hidden-import=modulename Testscript.py
you can also specify hidden-import in the .spec file.
Add hook file with name hook-encodings.py to C:\Python\Lib\site-packages\PyInstaller\hooks location and add following line of code to collect encodings module in hook file
from PyInstaller.utils.hooks import collect_submodules
hiddenimports = collect_submodules('encodings')
this may work,
this answer might help you Pyinstaller Error for Djnago project "ImportError: No module named 'django.contrib.admin.apps'"
Which windows version are you using (7 or 10) ?
This issue seems to be relative to user privilege ... and assuming it is similar to this issue, you may first try to run your exe file with administrator privilege, and if it is failling again, try to run "Pyinstaller" from a cmd.exe running with administrator right.
I am a python noob, so this may be a stupid question, but when I tried to use cxfreeze to export a python script to exe (using python 3.3) I get this:
cxfreeze.py: error: script or a list of modules must be specified
This is the command I was using:
cxfreeze.py script.py --target-dir dist
The script had been copied into the C:\Python33\Scripts directory. What am I doing wrong here?
I had a similar command working... then it stopped. Turns out that adding C:\Cygwin64\bin to my path causes that message to come up and without cx_Freeze works fine. Note that I do have both Windows and Cygwin Python installs so I assume that my issue is related to conflicting libraries being found.
Note that I am actually calling MinGW Make from a cmd.exe prompt in Windows 7 against a makefile which calls cx_Freeze using Python 3.4.