pyinstaller command not found

26,835

Solution 1

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

python -m PyInstaller myscript.py

Solution 2

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

pip3 install pyinstaller

Solution 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.

Solution 4

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.

Share:
26,835
Eric Smith
Author by

Eric Smith

Updated on July 09, 2022

Comments

  • Eric Smith
    Eric Smith almost 2 years

    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.

  • 2e0byo
    2e0byo over 2 years
    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 Review
  • jonathask
    jonathask over 2 years
    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).
  • jonathask
    jonathask over 2 years
    Changed the answer a bit in order to make it clearer and more informative.
  • 2e0byo
    2e0byo over 2 years
    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. ...
  • 2e0byo
    2e0byo over 2 years
    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 :)
  • 2e0byo
    2e0byo over 2 years
    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.
  • jonathask
    jonathask over 2 years
    My bad. Thanks for the tips though.