文章目录
- 步驟一:更新
- 步驟二:安裝對應的LIB
- 步驟三:下載Python
- 步驟四:解壓縮並且編譯
- 步驟五:安裝
- 步驟六:建立連結
- 步驟七:移除因為安裝所存留的暫存檔
- 步驟八:確定是否成功
步驟一:更新
sudo apt-get update
步驟二:安裝對應的LIB
sudo apt-get install -y build-essential tk-dev libncurses5-dev
libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev
libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev
liblzma-dev zlib1g-dev libffi-dev
步驟三:下載Python
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
步驟四:解壓縮並且編譯
tar xf Python-3.7.0.tar.xz
cd Python-3.7.0
./configure --prefix=/usr/local/opt/python-3.7.0
make -j 4
步驟五:安裝
sudo make altinstall
步驟六:建立連結
Make Python 3.7 the default version, make aliases
sudo ln -s /usr/local/opt/python-3.7.0/bin/pydoc3.7 /usr/bin/pydoc3.7
sudo ln -s /usr/local/opt/python-3.7.0/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/local/opt/python-3.7.0/bin/python3.7m /usr/bin/python3.7m
sudo ln -s /usr/local/opt/python-3.7.0/bin/pyvenv-3.7 /usr/bin/pyvenv-3.7
sudo ln -s /usr/local/opt/python-3.7.0/bin/pip3.7 /usr/bin/pip3.7
alias python='/usr/bin/python3.7'
alias python3='/usr/bin/python3.7'
步驟七:移除因為安裝所存留的暫存檔
cd ..
sudo rm -r Python-3.7.0
rm Python-3.7.0.tar.xz
. ~/.bashrc
步驟八:確定是否成功
python -V