Problem with making .exe from python file by PyInstaller - python

My script .py work perfectly, but .exe sadly doesn't work. Im running on newest PyInstaller.
Here is my script
I already tried everyting that i can think of here is options that i used:
Options used
-w : does't have .exe file
-- onefile -w and -F -w : The specified module could not be found.
--F , --onefile and no option used : Only shows this option for like half a second

Not all python code can be compiled into a .exe.

I was able to work around this issue by importing pywintypes into my script before win32print module.

Related

Nuitka can't open the .py file for compiling it

[So I have previously used nuitka to create standalone executables for my python scripts and had no issue until this time I tried once again]
I am trying to use nuitka to create a .exe file for my .py script however, it throws the following error:
Nuitka:INFO: Starting Python compilation.
__main__.py: can't open file 'MyPythonProgram.py'.
I have given the following command in the command prompt (run as administrator and in the correct directory):
nuitka --mingw --follow-imports MyPythonProgram.py
I have also tried using --onefile --windows-onefile-tempdir and standalone however the result was the same.
I am using python 3.9.4 and nuitka 0.6.14.4. (Same as last time when it actually worked without throwing any errors)
So let me know, what went wrong with my attempt and how to fix it...
Thanks in advance!

pyinstaller working but .exe application not staring up

I tried to convert my python gui application (.py ) to an executable file(.exe) using the pyinstaller module. I ran the following command in the terminal -
pyinstaller.exe --onefile -w sourcecode.py
The process was completed successfully and I got the .exe file(sourcecode.exe) along with the extra folders like pycache and sourcecode. But when I tried to run the .exe file/application by double clicking on it the app didn't start up and gave an error. Please help.
Try adding this --hidden-import to pyinstaller.exe --onefile -w sourcecode.py in case of hidden modules.
You can also try adding --debug to see what the error actually is.

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, PyInstaller error: no module named "Encodings" and system codec missing

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.

How do I run a Python 3.5 program that uses Tkinter on a computer without Python installed?

I have coded a program in Python 3.5 that uses the Tkinter import. I'm trying to figure out a way to run it on computers that don't have Python. First I tried freezing it but I haven't been able to because none of the freezing tools I found support Python 3.5. Then I tried possibly using a online idle but I couldn't find any that support Tkinter. I would prefer to be able to get a .exe file or something similar but if I could run it online that would be good too any ideas?
EDIT
So I have now successfully downloaded PyInstaller using pip. My current problem is when I type this into the console: pyinstaller.exe --onefile --windowed Finder.py
I get this error: 'pyinstaller.exe' is not recognized as an internal or external command,
operable program or batch file.
EDIT
I have now found the pathway to pyinstaller.exe. Now when I try to use it it says Access is denied.
I finally figured it out after about three days of work. Fist I downloaded PyInstaleller in the zipped form and extracted it. Then I put my program in the PyInstaller folder. Then I opened a regular command prompt. I then typed cd then the location of the PyInstaller folder. Finally I typed pyinstaller.py --one file --windowed program.py. Then when I went into the PyInstaller folder there was a folder called program with the .exe file in the dist folder. Thanks everyone for all of your help!
You can use pyinstaller to do that. I think its work fine on linux em linux.
Another option is use py2exe.
Try pyinstaller -F -w Finder.py as the command or you could check out CxFreeze.

Categories