Python 3.7.10 Compilation and Installation Tutorial#
Install Compilation Basics#
If you are using Ubuntu or Debian, use the following command to install. If you are using an Arch system, you do not need to install. If you have installed a desktop environment, the basic package components are complete.
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
Download the Source Code#
wget https://www.python.org/ftp/python/3.7.10/Python-3.7.10.tar.xz
Unzip
tar -zxvf Python-3.7.10.tar.xz
cd Python-3.7.10
Execute Configuration File, Compile, and Install#
./configure --prefix=/usr/local/python37
make
sudo make install
Configure Environment Variables#
Default installation path
usr/local/python37
You can use the following command to temporarily add Python 3.7 to the environment variables:
export PATH=/usr/local/python37/bin:$PATH
If you want to make this change permanent, you can add the above command to the ~/.bashrc
file as shown below:
echo 'export PATH=/usr/local/python37/bin:$PATH' >> ~/.bashrc
After reopening the terminal, you should be able to use the python3.7
command to call Python 3.7.
After configuring the environment variables, you can use pip3.7 or python3.7 to call the compiled and installed Python for testing.
This concludes the tutorial.