我正在尝试安装Python 3.7在我的 Ubuntu 18.04 服务器上。遵循以下指示:
https://phoenixnap.com/kb/how-to-install-python-3-ubuntu
sudo apt update
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7
但在那之后,如果我这样做:
root@west:~# python --version
Python 2.7.17
我做错了什么?如果我尝试再次安装,它会告诉我它已经安装?
root@west:~# sudo apt install python3.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.7 is already the newest version (3.7.7-1+bionic1).
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
答案1
两者都已安装,但有一个链接指向 python2.7。
如果你这样做,ls -l /usr/bin/python
它将指向 python2.7 如下所示:
root@5d9377c79b0c:/# which python
/usr/bin/python
root@5d9377c79b0c:/# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 Apr 16 2018 /usr/bin/python -> python2.7
root@5d9377c79b0c:/# which python3.7
/usr/bin/python3.7
删除链接并创建新链接python3.7
rm /usr/bin/python
ln -s /usr/bin/python3.7 /usr/bin/python
root@5d9377c79b0c:/# python --version
Python 3.7.5