我需要安装 Python 版本 2 (2.7) 才能使用 Nvidia Jetson TX2。它似乎无法安装。有人知道这个问题吗?提前谢谢。
我运行了这个命令
python -version
并得到这个输出
Command 'python' not found, but can be installed with:
sudo apt install python3
sudo apt install python
sudo apt install python-minimal
You also have python3 installed, you can run 'python3' instead.
然后我运行这个命令
sudo apt install python
然后收到此消息
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python : PreDepends: python-minimal (= 2.7.15~rc1-1) but it is not going to be installed
Depends: python2.7 (>= 2.7.15~rc1-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
答案1
虽然我对 Ubuntu 的使用经验不多,但从错误中我能理解的是,你可能需要重新安装原始软件包,因为它们可能一开始就没有正确安装。输入以下命令可能会通过重新安装它要求的依赖项来帮助解决问题:
sudo apt install python-minimum
sudo apt install python2.7
此外,正如它所说 python3已安装(不是 python),则输入的第一个查找版本命令应该是:
python3 --version
答案2
当您对 Ubuntu 说“安装 python”时,由于 Python 2.x 和 Python 3.x 现在共存,“python”可以是 Python 2.x 或 3.x。您需要明确指定 Python 2 或 3。
Python 2 和 Python 3 有一些不兼容的差异。您看到的错误是由于 Ubuntu 的 apt 树设置为不安装 python,除非您告诉它安装 2.x 或 3.x。通过“sudo apt install python2.7”或 python2.7-minimal,您的问题应该会消失。
编辑:顺便说一句,如果您安装 Ubuntu 18.04LTS Mate,则默认情况下会安装 python2 和 python3。将 Ubuntu 更新到 18.04 也可能会解决您的问题。