How to deal with python pip in root mode on manjaro?

the problem with sudo pip install is that it will install things into the system. This will at some point conflict with your normal packaging system, so that you are unable to install updates.
Since pip seems to be very popular, we should think about the situation and how to handle it.

examples: https://archived.forum.manjaro.org/search?q=pip

2 Likes

First of all, one question: is there any need for pip to run as root?

no. it is the wrong thing to do in every case I've seen.

Archwiki suggests using install --user
https://wiki.archlinux.org/index.php/Python#Package_management

If you must use pip , use a virtual environment, or pip install --user to avoid conflicts with packages in /usr . It is always preferred to use pacman to install software.

OR
To use virtual environment for python (python3+):

https://packaging.python.org/tutorials/installing-packages/#optionally-create-a-virtual-environment

python3 -m venv <DIR>
source <DIR>/bin/activate

This will create a new virtual environment in the <DIR> subdirectory, and configure the current shell to use it as the default python environment.

And heres the basics (again no sudo):
https://pip.pypa.io/en/stable/
https://pip.pypa.io/en/stable/quickstart/

1 Like

sudo pip install is always wrong, time ago suggested a thing but didn't go far Setup by default virtual enviroments for programming languages

Hm so how would you think about a root-block for pip? Maybe with a message that pip does not support root mode on this system.

Hack or alias pip to use --user by deafult

Already, solved this. If you're intending to program with python you should be using pyenv.

From what I've seen, you can enforce the --user flag with env PIP_USER=yes, but would that be enough?

pip --user install to ~/.local/bin which had to be added to PATH: to launch things as usual Pyinstaller error

Is this a fixed path or also some XDG fallback like ~/.local/share is a fallback if XDG_DATA_HOME is not set? Do you know?

Is the default one

  --user                      Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows.
                              (See the Python documentation for site.USER_BASE for full details.)

yes, the executable will end up there in ~/.local/bin/, and some stuff also in ~/.local/lib/

..I swear I remember things being dropped in .local/bin being picked up in PATH automatically. But I must be going crazy, as it doesnt seem that way in front of me.

Forum kindly sponsored by