Ubuntu 24.04 LTS安装Python2失败解决
WLHG8PLUS 2024-06-12 17:07:25 阅读 79
Ubuntu 24.04 LTS安装Python2失败解决
安装Ubuntu24.04之后,安装python2会提示:
~/$ sudo apt install python2Reading package lists... DoneBuilding dependency tree... DoneReading state information... DonePackage python2 is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, oris only available from another sourceE: Package 'python2' has no installation candidate
解决方式:
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgzsudo tar xzf Python-2.7.9.tgzcd Python-2.7.9sudo ./configure --enable-optimizationssudo make altinstall
之后:
python2.7 -V~ Python 2.7.9sudo ln -sfn '/usr/local/bin/python2.7' '/usr/bin/python2'sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
设置可选择python版本:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2sudo update-alternatives --config python (选择切换Python版本)python --version (查看Python版本)
声明
本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。