Projects
Arch Linux Python

In order to use Python on your laptop, and install any Python package you need using pip, you will need to create a Python virtualenv and install these third-party Python packages into it. Indeed, Pacman manages installation of pacman-registered Python packages in the main, OS-wide Python interpreter. So, any package you may need to install via pip should go into a Python virtual env.

On my laptop, I decided to be the root user at anytime. More traditional people create a specific user, defining it as sudoer, being able to switch to root when it is needed. I decided to bypass this complexity and be root. One of my friends said I was dumb.

So let's be dumb and create a Python virtual env in root's home folder:

python -m venv /root/.venv

Then, insert, into files /root/.bashrc and /root/.bash_profile, the following line in order to enable this virtualenv at login:

source /root/.venv/bin/activate

You will know that you are in your virtual env because the shell prompt will indicate it via the .venv prefix, like in this example:

Then, ensure pip is configured with your virtualenv by typing:

pip --version

Here, it is the case: the output shows pip being within the python3.12/site-packages folder, inside your virtualenv:

pip 24.1.1 from /root/.venv/lib/python3.12/site-packages/pip (python 3.12)