I cannot generate my setup with pyInstaller. When I type command "pyinstaller -w -F myfile.py" here is error below:enter image description here
This question needs more clarity/ detail. You should check that you have properly installed pyinstaller and python and that your python code runs without errors. If it still does not work, you can try running the same command on a different OS (e.g. on a Windows PC if possible)
Related
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.
I am trying to make a program, but when I turn it into .exe it's unrecognized by windows protector. And when I tried to run it in virtual box (virtual pc) AVG Antivirus detects it as a rare file, and it deleted it when I ran the program, how do I make it secure? I used "auto py to exe" to turn python codes to exe.
Auto py to exe uses pyinstaller to convert it, It uses GUI so it's much easier to use. It also shows the command of the pyinstaller.
Probably your python to exe convertor has bad reputation. Try a popular one pyinstaller, using next steps:
Install pyinstaller through python -m pip install pyinstaller.
Package your python script e.g. example.py through pyinstaller --onefile --noupx example.py, result will be in file dist/example.exe.
I developing a GUI app in Python, the code works fine in PyCharm IDE. Now I want to convert into an exe for distribution.
My code works fine until I generate a single file exe with PyInstaller with -w option enable (command: pyinstaller -F -w ). If I omit -w option, the code works fine but the final exe shows unwanted console as well.
To find a solution, I searched and found this to be a suitable workaround:
Python Subprocess Popen with Pyinstaller
Therefore, I tried Recipe sub-process as described here:
https://github.com/pyinstaller/pyinstaller/wiki/Recipe-subprocess
However, this is not working for me and I still get the error where subprocess command fails.
Anybody been in this situation, please help.
I am using Python 3.5, PyInstaller version 3.2.1.
I'm trying to generate an executable from Linux for Windows using pyinstaller.
pyinstaller --onefile --windowed montecarlo.py
I run this command and get a single executable that works on Linux just fine, but if I try on Windows, it's just a simple file. Why?
I was trying to do this same thing today and ran across this answer. It pointed to the FAQ, which says cross-compiling is not supported. It recommends using Wine.
I use Ubuntu, Python 3.4 and try to compile my py scripts to exe using py2exe.
Unfortunately When I try to use command 'build_exe', it generates error!
Could anybody help me to solve it or advise how to compile py project to exe in another way?
Error code:
NameError: name 'WinDLL' is not define.
py2exe is for windows...
On linux you can try PyInstaller:
http://www.pyinstaller.org/
PyInstaller is now able to build Windows executables when running
under Linux. See documentation for more details.
The py2exe module needs to be run from within a command prompt shell (aka Windows terminal) to make a Windows executable, since just like pyinstaller, "they use the OS support to load the dynamic libraries, thus ensuring full compatibility". That's why you get the ''WinDLL' is not defined' error when using the py2exe module in a bash shell.
py2exe works until python-3.4 and pyinstaller works until python-3.7. The latest version at time of writing is 3.8. Use the python module virtualenv from command prompt to get the adeqaute python version running (without replacing your current python set-up), and make your executable file. Here is my answer with code. --> Make sure to add python to your Windows path on install, so you can use the pip and python commands in command prompt. Otherwise you have to replace these commands in my answer for their fullpath, e.g. C:\Users\jakethefinn\python37\pip.exe and C:\Users\jakethefinn\python37\python.exe respectively.
If you install python from Microsoft Store, the files pip.exe and python.exe are automatically added to path.