Search code examples
pythonpython-3.xlinuxdebiandebian-buster

Attempting to clean up python installation in a Debian 10 instance


I received the following error message when I installed some python packages in a debian instance: WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

There are packages installed under /usr/local/lib/python3.7, /usr/local/lib/python2.7 and /home/oliver/.local/lib/python3.7 The packages under /usr/local/lib are owned by root and the packages under /home/oliver/.local/lib are owned by oliver

Some version information:
Debian: 10
python3 -V : 3.7.3
python -V : 2.7.16
pip3 -V (and pip -V): 22.0.3

The primary question I have at this point is where should the python 3 packages ideally reside (and with what permissions) so as to be accessible to all users?


Solution

  • The packages are correctly installed. The reason it asks for root permission in order to use pip is that there are two main ways to install/uninstall python packages. The first is through the package manager of the linux distro and the other through pip. When we want to code/experiment with Python and need some new Python package it's recommended to use Virtualenv which creates an isolated Python installation that doesn't interfere with your Linux installation. So you can do whatever you want with this and if something goes wrong you just delete it and there is no problem. As you see this is just a WARNING that you got from Debian. If you insist you can login as root and use pip to install without Virtualenv.