Pyinstaller command not found (MacOS)

2019-08-14 20:27发布

问题:

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.

回答1:

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


回答2:

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.



回答3:

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