当前位置:   article > 正文

Ubuntu 24.04 LTS安装Python2失败解决_ubuntu 24.04 python2

ubuntu 24.04 python2

Ubuntu 24.04 LTS安装Python2失败解决

安装Ubuntu24.04之后,安装python2会提示:

~/$ sudo apt install python2

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python2' has no installation candidate
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

解决方式:

wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
sudo tar xzf Python-2.7.9.tgz
cd Python-2.7.9
sudo ./configure --enable-optimizations
sudo make altinstall
  • 1
  • 2
  • 3
  • 4
  • 5

之后:

python2.7 -V
~ Python 2.7.9
sudo ln -sfn '/usr/local/bin/python2.7' '/usr/bin/python2'
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
  • 1
  • 2
  • 3
  • 4

设置可选择python版本:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3  2
sudo update-alternatives --config python  (选择切换Python版本)
python --version (查看Python版本)
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/943624
推荐阅读
相关标签
  

闽ICP备14008679号