Ubuntu20.04 源码安装 Python3.9

2021/3/5 UbuntuPython

# Install Python 3.9 Using Source Code

As the Debian packages are available, We don’t recommend to install Python 3.9 packages from source code. But in some cases you may need to install Python from source code.

So follow the below instructions to install Python 3.9 using source code on Ubuntu 20.04 Linux system.

# First, install essential packages for compiling source code. Open a terminal and execute following commands

sudo apt install wget build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

# Now, download the Python 3.9 source code from official download site. Switch to a relevant directory and use wget to download source file

cd /opt 
sudo wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz 

# Next, extract the downloaded archive file and prepare the source for the installation

tar xzf Python-3.9.0.tgz 
cd Python-3.9.0 
sudo ./configure --enable-optimizations 

# Python source is ready to install. Execute make alt installation command to install Python 3.9 on your system

sudo make altinstall 

# The Python 3.9 has been installed on Ubuntu 18.04 system. Verify the installed version

python3.9 -V 

# Remove the downloaded archive to free space

sudo rm -f /opt/Python-3.9.0.tgz 
最近更新: 7 个月前