How to convert a PY to EXE using PyInstaller - python

So this is what I tried. I found out the hard way that "PIP INSTALL" does not work for me. Not sure if it is a Windows thing or I need less ID10T on my keyboard. After much weeping and gnashing of teeth, the PATH to Python is added to the Window thingy. When you live in Florida, googling "Python Path" shows the Everglades, so this is easier said than done. Even after the path is added, "PIP" STILL does NOT work.
But this command DOES work for PIP Install
python -m pip install pyinstaller
Not sure why, but it works with "PYTHON -M" prefix, so I go with it. So I see a bunch of responses indicating that Pyinstaller is installed. Here are a few snippets:
Successfully built pyinstaller
Successfully installed altgraph-0.17 future-0.18.2 pefile-2021.5.24 pyinstaller-4.3
pyinstaller-hooks-contrib-2021.1 pywin32-ctypes-0.2.0
Where? No clue. I ran it in the folder of my PY file that I want to convert. No indication that it is there. Now, when I try to run PYINSTALLER using the same trick as PIP, I hit the next wall.
python -m pyinstaller --onefile main.py
No module named pyinstaller
Any direction to get to the next step is appreciated. Do I need to add another path for "PIP Installed items"??
UPDATE: I am not sure why a space makes such a big difference, but here is a summary of what finally worked
A>Pyinstaller --onefile main.py
B>python -m Pyinstaller --onefile main.py
C> python -m PyInstaller --onefile main.py
A and B did NOT work. C did work. C is B with an added space at the beginning. Yeah...baffles me too.

Related

how to convert pyw to exe

I have installed pyinstaller like this pip install pyinstaller as a Youtube video said to convert pyw to exe.
Then the tutorial said to convert pyw to exe you need to type pyinstaller -w filename.pyw
, but this doesn't work for me why?
pyinstaller is not a command on your system's PATH, which means that your terminal cannot find it. Because it is a Python module, you may be able to run it with python -m pyinstaller -w main.pyw. This -m <name> specifies that we wish to run a Python module with the given name.
Alternatively, you can add the location of the pyinstaller folder to your PATH. However, this requires finding out where pyinstaller was installed with pip, too. I've generally used the former strategy, and that's the strategy I recommend.

pyinstaller downloaded using pip not working after installation

Screenshot of error
I'm trying to install a module called pyinstaller from pip to make .py files into an executable, but can't run it from command prompt. Any ideas as to why it doesn't work or workarounds with other applications that serve the same purpose?
try changing directory to where python location is and try installing again
i.e C:\Users--------------------\AppData\Local\Programs\Python\Python39> pip install pyinstaller

PyInstaller on cygwin

I need to create an .exe file from a .py file on cygwin. Since py2exe doesn't seem to work there, I tried PyInstaller. However I have a problem installing it. pip install pyinstaller returns this message:
ERROR: Failed compiling the bootloader. Please compile manually and rerun setup.py
So I tried to follow this guide: https://pyinstaller.readthedocs.io/en/latest/bootloader-building.html and install it manually. But when I run pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz the folder that I get for PyInstaller is not https://github.com/pyinstaller/pyinstaller but this one: https://github.com/pyinstaller/pyinstaller/tree/develop/PyInstaller in which there are no waf files and I can't run python ./waf all.
So I downloaded the needed folder from github manually and then python ./waf all succeded. However, I still can't not use PyInstaller since I get this error when trying to call it from command line:
ModuleNotFoundError: No module named 'PyInstaller.__main__'
And I have no clue how to fix it. What should I do to get PyInstaller working or maybe I need to to use some other module that works with cygwin?

.py to .exe file conversion issue

I'm trying to convert a simple python code (any sample code) into an executable file but on opening the application all I can see is a blank black screen.
I am using:
Python 3.7
PyInstaller 3.6
One file output
I am able to convert the file to .exe using auto-py-to-exe but I don't see any output when I try to run the application.
Pyinstaller is much easier than other things, you need to install with pip:
pip install pyinstaller
And then go to the path of your Python file and then:
pyinstaller -w -F my_file.py
In general there are some different ways so you can try the below and see if the issue is solved.
auto-py-to-exe is "A .py to .exe converter using a simple graphical interface built using Eel and PyInstaller in Python.". You can find a quick guide here
PyInstaller "freezes (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX." You can find more usage info here (also pointed out by #nakE)
py2exe "is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.".You can find more usage info here (also as pointed out by #Kompocik)
If it is not solved then I am pretty confident that there is an issue with the executed code per se and not the conversion.
Can you please share your code so we can have a look?
Try doing this in order:
py -3.7 -m pip uninstall pyinstaller
py -3.7 -m pip install pyinstaller
pyinstaller --onefile test.py

Pyinstaller command not found (MacOS)

I've been trying to use PyInstaller on my program, scratch_1.py. The PyCharm project folder is called "idigen", which is saved in my desktop. So, I changed the director like so:
cd /Users/joelsaarinen/Desktop/idigen
then, moved on to use pyinstaller, and I get this error:
pyinstaller scratch_1.py
-bash: pyinstaller: command not found
I'm confused because when I use:
pip show pyinstaller
to verify that I have pyinstaller installed, it returns a positive result.
Is there an additional command I should be putting in when using Pyinstaller on one of my files? Might this be an issue with this specific program or the operating system in general? Thanks in advance.
This is a common problem due to the fact that you might install a different version of python and keep using an old version that is preinstalled in the machine. Here is the best solution.
First, check the version of the python that you installed. In my case, i installed python 3.5 and the machine had python2.7. If you run python on the terminal, most likely the preinstalled one is the one that will run.
Second, check the directory of your desired python version. watch -a python3 is the command to run to see your directory.
Third, set the directory as the main one to run your python commands.
alias python=/usr/local/bin/python3 does the whole trick
Lastly, reinstall pip. Download the get-pip.py file and run sudo /usr/local/bin/python3 get-pip.py * I used the path to show the reason we updated the alias*
Now you can run pyinstaller without problems
pyinstaller appears to have installed correctly, but the command is not available on PATH. You need to locate where the executable was placed.`below to find executables
set | grep pyinstaller
now modify path by this
export PATH=some_path:another_path
launchctl setenv PATH $PATH
I just downloaded the source code of pyInstaller from official website, put it where I can find it and wrote a script which launches pyinstaller.py from that folder.
For some reason, pyinstaller.py is missing in the pyInstaller installation downloaded via pip.
I had the same issue on MacOS with Developer Tools 11.4 and found two ways to start pyinstaller:
alt 1: path based solution
$ pip3 show -f pyinstaller|grep pyinstaller
will find pyinstaller in a bin path:
../../../../usr/local/bin/pyinstaller
...
So you can use one of the set-the-path-or-an-alias approaches or call via fully qualified path.
alt 2: call via python module
$ pip3 show -f pyinstaller|grep __init__
will get you a hint on how pyinstaller is defined as a module:
PyInstaller/__init__.py
...
With that capitalization, it's possible to call pyinstaller as a module with the following:
$ python3 -m PyInstaller --version
4.2
I'm using the latter now.

Categories

Resources