Here’s a guide to setting up Python on Debian and CentOS:
First, update your package list to make sure you’re installing the latest versions of the software.
sudo apt update
Debian typically comes with Python pre-installed. You can check the installed version with:
python3 --version
If Python 3 is not installed or you want to install a specific version, run:
sudo apt install python3
pip (Python Package Manager)pip is essential for installing Python packages.
sudo apt install python3-pip
Check that both Python and pip are correctly installed:
python3 --version
pip3 --version
To create isolated environments for different projects, you can use venv:
venv:sudo apt install python3-venv
python3 -m venv myenv
source myenv/bin/activate
Start by updating the system’s package list:
sudo yum update
CentOS 7 comes with Python 2.x by default, and you might want to install Python 3.
For CentOS 7:
sudo yum install -y python3
For CentOS 8:
sudo dnf install -y python3
pipEnsure pip is installed for Python package management:
sudo yum install python3-pip
Check Python and pip versions to confirm successful installation:
python3 --version
pip3 --version
For isolated environments, install and use venv:
venv module:sudo yum install python3-venv
python3 -m venv myenv
source myenv/bin/activate
If you need a specific version of Python, such as 3.9 or 3.10, you can install it manually on either Debian or CentOS using source code or package managers like pyenv or deadsnakes for Debian.