To make the Python environment not externally managed on Debian 12, you can follow these steps:
-
Update your system's package list:
sudo apt update
-
Install pip3 (if not already installed):
sudo apt install python3-pip
-
Upgrade pip to the latest version:
pip3 install --upgrade pip
-
Remove any existing virtual environments (optional):
-
Configure pip to install packages globally by creating a
pip.conf
file:a. Create the directory if it doesn't exist:
mkdir -p ~/.config/pip/
b. Create the
pip.conf
file using a text editor of your choice:nano ~/.config/pip/pip.conf
c. Add the following content to the file and save it:
[global] user = true
-
Now you can directly use
pip3
to install packages globally without worrying about virtual environments.
Please note that installing packages globally may affect system-wide Python dependencies and could potentially cause conflicts between different applications or versions of Python modules. It is generally recommended to use virtual environments for isolating project-specific dependencies whenever possible, as it helps maintain better control over package versions and avoids potential conflicts with other applications on your system.