Install python on debian¶
Unlike ubuntu, debian does not provide a python interpreter by default. So we need to install it by ourself.
In this tutorial, we will build the python from source
Get the python source¶
You can download the python source from their official site.
For example, I download the 3.10.7 with below command
wget https://www.python.org/ftp/python/3.10.7/Python-3.10.7.tgz
tar -xzvf Python-3.10.7.tgz
Build from source¶
cd Python-3.10.7
# setup configure
./configure --enable-optimizations
# start the build
# The value -j 2 represents the number of CPU cores that can be used
sudo make -j 2
# Check it with nproc command.
nproc
# it should returns 2
# install the binary
sudo make altinstall
# if everythin works well. You should be able to run
python3 -V
Python 3.10.7
The -–enable-optimizations flag optimizes the Python binary and executes multiple tests.
Upgrade pip and install package¶
python3 -m pip install --upgrade pip
python3 -m pip install <module_name>