pyinstaller command not found

Question:

I am using Ubuntu on VirtualBox. How do I add pyinstaller to the PATH?

The issue is when I say

pyinstaller file.py

it says pyinstaller command not found

It says it installed correctly, and according to other posts, I think it has, but I just can’t get it to work. I ran:

pip install pyinstaller

and

pyinstaller file.py 

but it won’t work. I think I need to add it to the shell path so Linux knows where to find it.

pip show pyinstaller works.

Asked By: Eric Smith

||

Answers:

There is another way to use pyinstaller using it as a Python script.

This is how I did it, go through pyinstaller’s documentation

Create a Python script named setup.py or whatever you are comfortable with.

copy this code snippet to the setup.py:

import PyInstaller.__main__
import os
    
PyInstaller.__main__.run([  
     'name-%s%' % 'name_of_your_executable file',
     '--onefile',
     '--windowed',
     os.path.join('/path/to/your/script/', 'your script.py'), """your script and path to the script"""                                        
])

Make sure you have installed pyinstaller.
To test it:

  1. open the terminal
  2. type python3
  3. type import PyInstaller

If no errors appear then you are good to go.

Put the setup.py in the folder of your script. Then run the setup.py

This was tested in Python3.

You can use the following command if you do not want to create additional python file.

python -m PyInstaller myscript.py
Answered By: shmsi

Come across the same issue today. In my case, pyinstaller was sitting in ~/.local/bin and this path was not in my PATH environment variable.

Answered By: vincent.voyage

Just get root access first by running sudo -i
and then installing pyinstaller again:

pip3 install pyinstaller

You could do a echo $PATH to see the content of it, an then create a symbolic link from one of the directories listed on $PATH to the current location of your pyinstaller:

sudo ln -s ~/.local/bin/pyinstaller /usr/local/sbin/pyinstaller

On the above case, usr/local/sbin/ is the path already listed on $PATH.

Answered By: jonathask

python3 -m PyInstaller file.py worked in my case on Ubuntu 22.04 LTS.

Answered By: Keldro