我在Ubuntu上安装Python遇到了一个令人困惑的情况。
我想要的只是在命令“python”下执行python3.4。因此,我将/usr/bin/python3复制到/usr/bin/python,因为“python --version”返回2.7,现在返回3.4。我不知道这是否是一个错误。
我尝试使用pip安装软件包,但失败了。然后我尝试重新安装python(sudo apt-get install --reinstall python),终端给了我提示运行“apt-get -f install”而不需要软件包名称。
我已经尝试过将链接改回来了。
我应该怎么做才能同时安装Python2和Python3?如何使用apt-get重新安装Python?
$ python --version
Python 3.4.0
$ python2 --version
Python 3.4.0
$ python3 --version
Python 3.4.0
$ ls -la /usr/bin/python2
lrwxrwxrwx 1 root root 9 Dez 21 2013 /usr/bin/python2 -> python2.7
$ ls -la /usr/bin/python3
lrwxrwxrwx 1 root root 9 Mär 23 2014 /usr/bin/python3 -> python3.4
我想要的只是在命令“python”下执行python3.4。因此,我将/usr/bin/python3复制到/usr/bin/python,因为“python --version”返回2.7,现在返回3.4。我不知道这是否是一个错误。
我尝试使用pip安装软件包,但失败了。然后我尝试重新安装python(sudo apt-get install --reinstall python),终端给了我提示运行“apt-get -f install”而不需要软件包名称。
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
8 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python2.7 (2.7.6-8) ...
File "/usr/lib/python2.7/py_compile.py", line 114
except Exception,err:
^
SyntaxError: invalid syntax
dpkg: error processing package python2.7 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python:
python depends on python2.7 (>= 2.7.5-1~); however:
Package python2.7 is not configured yet.
dpkg: error processing package python (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-dateutil:
python-dateutil depends on python (>= 2.7); however:
Package python is not configured yet.
python-dateutil depends on python (<< 2.8); however:
Package python is not configured yet.
python-dateutil depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.
dpkg: error processing package python-dateutil (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-gst-1.0:
python-gst-1.0 depends on python (>= 2.7); however:
Package python is not configured yet.
python-gst-1.0 depends on python (<< 2.8); however:
Package python is not configured yet.
python-gst-1.0 depends oNo apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
n python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.
dpkg: error processing package python-gst-1.0 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-pyparsing:
python-pyparsing depends on python (>= 2.7); however:
Package python is not configured yet.
python-pyparsing depends on python (<< 2.8); however:
Package python is not configured yet.
python-pyparsing depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.
dpkg: error processing package python-pyparsing (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-tz:
python-tz depends on python (>= 2.7); however:
Package python is not configured yet.
python-tz depends on python (<< 2.8); however:
Package python is not configured yet.
python-tz depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.
dpkg: error processing package python-tz (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-support:
python-support depends on python (>= 2.5); however:
Package python is not configured yet.
dpkg: error processing package python-support (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-matplotlib:
python-matplotlib depends on python-dateutil; however:
Package python-dateutil is not configured yet.
python-matplotlib depends on python-pyparsing; however:
Package python-pyparsing is not configured yet.
python-matplotlib depends on python-tz; however:
Package python-tz is not configured yet.
python-matplotlib depends on python (<< 2.8); however:
Package python is not configured yet.
python-matplotlib depends on python (>= 2.7); however:
Package python is not configured yet.
python-matplotlib depends on python-support (>= 0.90.0); however:
Package python-support is not configured yet.
dpkg: error processing package python-matplotlib (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python2.7
python
python-dateutil
python-gst-1.0
python-pyparsing
python-tz
python-support
python-matplotlib
E: Sub-process /usr/bin/dpkg returned an error code (1)
$
我已经尝试过将链接改回来了。
$ sudo cp /usr/bin/python2.7 /usr/bin/python
$ python --version
Python 3.4.0
$ sudo cp /usr/bin/python2 /usr/bin/python
$ python --version
Python 3.4.0
$
我应该怎么做才能同时安装Python2和Python3?如何使用apt-get重新安装Python?