本文介绍在deepin 20系统上安装python3.8版本的方法,及提供安装python3.8的shell脚本,如果需要安装不同的python版本,只需要改python_version变量即可。
安装步骤如下 export python_verion=3.8.5 wget -P/tmp https://www.python.org/ftp/python/${python_verion}/Python-${python_verion}.tgz sudo apt-get install libffi-dev cd /tmp tar xvf Python-${python_verion}.tgz cd Python-${python_verion} ./configure --prefix=/usr/local/Python-${python_verion} --with-openssl=/usr make -j4 sudo make install echo "# Set environment for Python" >> ~/.bashrc echo "export LD_LIBRARY_PATH=/usr/local/Python-${python_verion}/lib:\$LD_LIBRARY_PATH" >> ~/.bashrc echo "export PATH=/usr/local/Python-${python_verion}/bin:\$PATH" >> ~/.bashrc source ~/.bashrc
shell脚本如下 已把它写成shell脚本,直接运行,要是安装其他的版本,要更改下面的python_version变量。 #!/bin/bash # Set Python version to be installed export python_version=3.8.5 # Install dependency package sudo apt install libffi-dev # Download Python tarball wget -P/tmp https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz # Build and install Python cd /tmp tar xvf Python-${python_version}.tgz cd Python-${python_version} ./configure --prefix=/usr/local/Python-${python_version} --with-openssl=/usr make -j2 sudo make install # Set environment for using new Python echo "" >> ~/.bashrc echo "# Set environment for Python" >> ~/.bashrc echo "export LD_LIBRARY_PATH=/usr/local/Python-${python_version}/lib:\$LD_LIBRARY_PATH" >> ~/.bashrc echo "export PATH=/usr/local/Python-${python_version}/bin:\$PATH" >> ~/.bashrc source ~/.bashrc
相关说明 假设从源代码编译安装到/usr/local/Python-3.8.5,需要设置环境变量: echo "export LD_LIBRARY_PATH=/usr/local/Python-3.8.5/lib:\$LD_LIBRARY_PATH" >> ~/.bashrc echo "export PATH=/usr/local/Python-3.8.5/bin:\$PATH" >> ~/.bashrc source ~/.bashrc 运行Python3.8.5: $ which python3 /usr/local/Python-3.8.5/bin/python3 $ python3 --version Python 3.8.5 如果要恢复使用深度初始安装的Python 3.7,在~/.bashrc里注释或删除以下两行,然后运行"source ~/.bashrc": export LD_LIBRARY_PATH=/usr/local/Python-3.8.5/lib:$LD_LIBRARY_PATH export PATH=/usr/local/Python-3.8.5/bin:$PATH
相关主题 |