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.
Related
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
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.
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
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.
I am trying to convert a .py file to an exe. My file, hello.py, reads:
print "Hello, World!"
I am currently trying to use pyinstaller. However when I run the command
pyinstaller hello.py
I get the error message "tuple index out of range" which I have been told means my version of python is unsupported. In particular it would seem the situation is that pyinstaller thinks I am trying to compile python 3.6 code into an exe. But I have python 2.7 and python 3.6 installed. How do I let it know that I want it to regard the code as python 2.7 code?
Using Python3:
Make sure PyInstaller is installed in Python 3.x: pip3 freeze
PyInstaller==3.3.1
Then running the command:
/path/to/python3 -m PyInstaller your_script.py
First install Pyinstaller in your python2.7 version if not installed previously
py -2 -m pip install pyinstaller
and then go to your folder and
py -2 -m pyinstaller -F filename.py
When you need to bundle your application within one OS but for different versions of Python and support libraries – for example, a Python 3 version and a Python 2.7 version; or a supported version that uses Qt4 and a development version that uses Qt5 – we recommend you use virtualenv. With virtualenv you can maintain different combinations of Python and installed packages, and switch from one combination to another easily. (If you work only with Python 3.4 and later, python3 -m venv does the same job, see module venv.)
Use virtualenv to create as many different development environments as you need, each
with its unique combination of Python and installed packages.
Install PyInstaller in each environment.
Use PyInstaller to build your application in each environment.
The answers have devolved in "How do I tell pyinstaller which python version to use?" So, I know that this doesn't really answer the original question. However, I wasted about an hour trying to figure this out so, in the hopes that others don't have to waste an hour... To force pyinstaller to use Python 3.9 under Windows do the following.
Given Windows and Python 3.9:
python3.9 -m PyInstaller [whatever options you want]
You have to type it as PyInstaller instead of pyinstaller (i.e. note the capitalization).
python3.9 -m pyinstaller
Produces an error:
C:\Users\chris.SR\AppData\Local\Programs\Python\Python39\python.exe: No module named pyinstaller
Supposing you have python 2.x on the path under python2 you can do
python2 -m pyinstaller hello.py
I ran two a couple things.
If you uninstall python3, it works with python2.
If you have python3 installed (and it is the primary), and have pyinstaller installed in python3, it wont work (python3 pyinstaller used).
If you have python3 installed, but do not have it installed in python3 or uninstalled it (pip3 uninstall pyinstaller), pyinstaller works.
Checking the environmental variables (windows 10) PATH had python3 first. This may be the issue and may not be resolved because it is checking python3 directories first, and picks up pyinstaller for python3. pyinstaller does not check the file either (#!/usr/env/bin python2).
Unless pyinstaller puts an option relating to this issue, there may be no solution short of uninstalling pyinstaller from python3 temporarily.
note
could also use py2exe, using py2exe for python2, pyinstaller for python3