pythonpipdebianapt

I can't install Pyinstaller from command line in Debian Linux


I wanted Pyinstaller on my Debian machine, so I ran the following command: sudo pip3 install pyinstaller This returned the following error:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

So then I ran this: sudo apt install python3-pyinstaller That returned this:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3-pyinstaller

I don't know what else to try. pip has been doing this, but usually using apt, I can install Python packages pretty easily.


Solution

  • As the error message states, you would need to install through apt to install globally, if that's not available for whaterver reason, the next best thing is to install that package into a virtual environment of some sort (e.g. with virtualenv env and then source env/bin/activate to activate the virtual environment). In my case there are some packages I would definitely not install in any other way and that I want to be able to use without activating any virtual environment whatsoever (e.g. bpytop, ps_mem) so just as the error says just pass --break-system-packages as you run pip3 install pyinstaller. To clarify, the command should look like this: pip3 install pyinstaller --break-system-packages