我将系统默认的 python 版本更改为 python2.7,但 apt-get 仍然使用 python2.6

我将系统默认的 python 版本更改为 python2.7,但 apt-get 仍然使用 python2.6

Ubuntu,我将系统默认的python版本从python2.6更改为python2.7。

sh-3.1$: update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2

sh-3.1$: sudo update-alternatives --config python

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/python2.7   2         auto mode
  1            /usr/bin/python2.7   2         manual mode
* 2            /usr/lib/python2.7   1         manual mode

Press enter to keep the current choice[*], or type selection number: 0
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode.

我想我改变了默认版本,命令python显示正常。

sh-3.1$: python
Python 2.7.1 (r271:86832, Jul 20 2011, 10:41:38) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

但在我跑完之后:

sh-3.1#: sudo dpkg --configure -a
Setting up opera (11.50.1074) ...
Traceback (most recent call last):
  File "/usr/sbin/update-software-center", line 21, in <module>
    import apt
ImportError: No module named apt
dpkg: error processing opera (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-piston-mini-client (0.3+bzr32-0ubuntu1) ...
Traceback (most recent call last):
  File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.6/py_compile.py", line 168, in <module>
    sys.exit(main())
  File "/usr/lib/python2.6/py_compile.py", line 160, in main
    compile(filename, doraise=True)
  File "/usr/lib/python2.6/py_compile.py", line 115, in compile
    f = open(file, 'U')
IOError: [Errno 2] No such file or directory: '-'
dpkg: error processing python-piston-mini-client (--configure):
 subprocess installed post-installation script returned error exit status 255
dpkg: dependency problems prevent configuration of software-center:
 software-center depends on python-piston-mini-client (>= 0.1+bzr29); however:
  Package python-piston-mini-client is not configured yet.
dpkg: error processing software-center (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 opera
 python-piston-mini-client
 software-center

该错误表明apt-get仍然使用的是python2.6版本。

我如何解决它?

答案1

尝试使用以下命令更新您的 apt-get:

sudo apt-get update

相关内容