pyinstaller command not found
Asked Answered
S

8

20

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.

Sexcentenary answered 16/12, 2018 at 1:21 Comment(4)
Where pip install puts anything depends on whether you have a virtualenv active, where your Python interpreter (the one backing pip) is located, etc. BTW, "won't work" isn't a particularly helpful description -- including the specific error message in the question itself would help folks affirm that your diagnosis (that it's a missing PATH entry that's the issue at hand) is correct.Negotiation
Thank you for your help. I wish I could include a better error message but that is all the terminal spits out. I’ve tried looking at other posts, and this is what I’ve concluded. I’m not sure how to change my PATH to make it work. The end game is to make a python file into an executableSexcentenary
"exits without printing an error message or taking any apparent action" is a lot more descriptive that "won't work", should that be the actual behavior at hand.Negotiation
BTW, pip install pyinstaller will (on Windows) generally put a pyinstaller.exe shim in the Scripts subdirectory of your Python install location (on UNIX-family systems the directory is called bin). Have you looked at whether it's there?Negotiation
D
74

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

python -m PyInstaller myscript.py
Dicky answered 2/1, 2020 at 13:42 Comment(0)
C
9

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

pip3 install pyinstaller
Corinthian answered 5/7, 2021 at 15:5 Comment(0)
M
3

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.

Myelencephalon answered 3/10, 2019 at 8:51 Comment(0)
B
3

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.

Backstay answered 23/10, 2020 at 22:47 Comment(0)
P
3

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.

Postpone answered 3/12, 2021 at 14:50 Comment(7)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewKragh
Thanks for the feedback and for pointing out the guidelines link. I do, however, don't see why it doesn't provide an answer to what was asked. I actually got this same problem and solved it following @vincent.voyage's tip. But, as the actual solution to the problem wasn't given - just why it was happening -, I felt a complement to that answer would fit (most ideally in a comment).Postpone
Changed the answer a bit in order to make it clearer and more informative.Postpone
If you start an answer with 'this should be a comment but I don't have the rep' you're asking for a review of 'should be a comment' ;) I did skim the rest of your answer, but saw no reason not to vote for deletion like you asked for with that opening clarification. That said, whilst I personally would have proposed an edit to @vincent.voyage's answer, I can see what this adds---the information that one can add something to $PATH with a symlink. I guess I grew up on *nix so that's obvious to me, but no harm in saying it. ...Kragh
I would reword this answer, removing the opening clarification, and noting that once you have determined that X isn't in your path, you need to add it to your path, either by editing $PATH or by symlinking. Rewritten like that on consideration I think it would fall on the 'accept' rather than 'vote for deletion' side. I am neither very experienced here nor infallible, but I'm pretty confident of that. (Doubtless there are clarificatory posts on Meta.) The comment above btw was autogenerated when I voted for deletion in the review queue. It wasn't meant to be personal :)Kragh
Incidentally to clairfy, one of the reasons for deletion is 'this should be a comment'. I.e. it's site policy not to comment in answers, and not to do so to work around the comment rep limit. I agree, though, that this post need not be merely a comment.Kragh
My bad. Thanks for the tips though.Postpone
H
2
python3 -m PyInstaller file.py

worked in my case on Ubuntu 22.04 LTS.

Heaney answered 22/11, 2022 at 21:25 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Musician
C
0

I know this is a bit unconventional, but I fixed this by moving my script to the place where pip installed pyinstaller and just ran the command from there: First:

pip3 show pyinstaller

Then navigate to the location of pyinstaller.exe

and finally:

$python3 pyinstaller.exe --onefile myscript.py

Worked for me.

Craniometer answered 12/1, 2024 at 12:37 Comment(0)
P
0

Hey bro this is a detailed guide to solve your problem

  1. Find Where PyInstaller is Installed: Run this command to see where PyInstaller is installed:

    pip show pyinstaller
    

    Look for the line that starts with Location:. This tells you where PyInstaller's files are.

  2. Locate the Executable: The actual pyinstaller executable will be in a bin directory under the path you found. You can find it by running:

    find ~/.local/bin -name pyinstaller
    

    or simply:

    which pyinstaller
    
  3. Add the Path to Your Shell Configuration: You need to add the directory where pyinstaller is located to your PATH. Open your shell configuration file with a text editor. If you're using Bash, you would edit .bashrc like this:

    nano ~/.bashrc
    

    Add this line at the end of the file, adjusting the path as needed:

    export PATH=$PATH:/home/username/.local/bin
    
  4. Apply the Changes: After saving the file, apply the changes by running:

    source ~/.bashrc
    
  5. Check if It’s Working: Finally, verify that pyinstaller is now accessible by running:

    pyinstaller --version
    
Paigepaik answered 3/8, 2024 at 14:35 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.