How to install packages from Pip on Ubuntu 23.04

Ubuntu is an ideal environment for programming in Python.

If you have no idea what this article is about, you don't need to read it as it is not something that everyone needs to know. SOnly those who program in the Python language using Ubuntu 23.04 they have to know how to install packages from pip.

For those who don't know what I'm talking about, but are curious, I'll tell you that Python It is a very powerful programming language and suitable for beginners and professional users. It has a number of libraries (Pprograms for specific functions that can be used by other programs) that can be installed in two ways: the distribution's traditional package manager or its own package manager known as Pip.

The issue is that the developers of Debian (the distribution on which Ubuntu is based) found that there were conflicts between the packages installed by one method and the other and, from now on when you try to install using Pip we receive a message that tells us that we are trying to install an external source package and suggests two paths:

  1. Install from official repositories.
  2. Create a virtual environment

If you are going to install from repositories I recommend installing the Synaptic package manager first. since the Ubuntu Software Center search engine is a real headache. do it with
sudo apt install synaptic.

How to install packages from Pip

The first thing we need is to install the following packages: python3-full y python3-pip
The first guarantees us to have all the tools to work with Python and the second installs the Pip package manager.
The commands are:
sudo apt install python3-full
sudo apt install python3-pip.

Creating virtual environments

In Python it is possible to create a sandbox of the main Python installation in which to install dependencies and libraries without modifying the main system or the other virtual environments. This allows for example to run test versions of a future version of a library or to check how a program works in different versions of Python.

Next, we create the virtual environment with the command:

python3 -m venv titulo_entorno
And we launch it with:

source titulo_entorno/bin/activate
And we installed the package that we wanted to install with
pip3 install nombre_paquete
We leave the virtual environment with
deactivate


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.