您可以Python-3.6
按以下步骤在Debian 8上安装:
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar xvf Python-3.6.9.tgz
cd Python-3.6.9
./configure --enable-optimizations --enable-shared
make -j8
sudo make altinstall
python3.6
建议make altinstall
根据官方网站使用。
如果要pip
加入,则需要添加--with-ensurepip=install
到您的配置调用中。有关更多详细信息,请参见./configure --help
。
警告:make install
可能会覆盖或伪装python二进制文件。make altinstall
因此建议使用而不是make install
因为它仅安装exec_prefix/bin/pythonversion
。
需要安装一些软件包来避免某些已知问题,请参阅:常见的构建问题(已更新)
Ubuntu / Debian:
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
libreadline-dev的替代方法:
sudo apt install libedit-dev
Fedora / CentOS / RHEL(aws ec2):
sudo yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel \
openssl-devel xz xz-devel libffi-devel
openssl-devel的替代方法:
sudo yum install compat-openssl10-devel --allowerasing
更新资料
您可以python-x.y.z.tar.gz
从此处下载最新版本。
要设置默认的python版本并在它们之间轻松切换,您需要update-alternatives
使用多个python版本进行更新。
假设您已经python3.7
在debian Stretch上安装了,请使用命令whereis python
找到二进制文件(*/bin/python
)。例如:
/usr/local/bin/python3.7
/usr/bin/python2.7
/usr/bin/python3.5
添加python版本:
update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 50
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 40
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 30
将python3.7
与50
现在当务之急是默认的Python中,python -V
将打印:
Python 3.7.0b2
要在它们之间切换,请使用:
update-alternatives --config python
样本输出:
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/local/bin/python3.7 50 auto mode
1 /usr/bin/python2.7 40 manual mode
2 /usr/bin/python3.5 30 manual mode
3 /usr/local/bin/python3.7 50 manual mode
Press <enter> to keep the current choice[*], or type selection number: