ubuntu 20.04 源碼安裝python 3.6.8
安裝依賴工具
sudo apt-get install -y gcc 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
下載源碼文件壓縮包
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
解壓源碼文件壓縮包
tar -xzf Python-3.6.8.tgz
配置
cd Python-3.6.8
sudo ./configure enable-optimizations prefix=/usr/local/bin/python3.6
- –prefix=/usr/local/bin/python3.6:編譯的時候用來指定程序存放路徑。
編譯
sudo make
安裝
sudo make install
設置軟鏈接
sudo ln -s -f /usr/local/bin/python3.6/bin/python3.6 /usr/bin/python3.6
sudo ln -s -f /usr/local/bin/python3.6/bin/pip3.6 /usr/bin/pip3.6