安装 python 后 python 损坏,无法运行 sudo apt-get upgrade

安装 python 后 python 损坏,无法运行 sudo apt-get upgrade

当我尝试运行 python 时出现以下错误:

$ python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

此外,当尝试运行时

sudo apt-get 升级

我的输出是

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 apport-gtk : Depends: python3-apport (>= 2.14.1-0ubuntu3.19) but 2.14.1-0ubuntu3.18 is installed
 bzr : Depends: python-bzrlib (>= 2.6.0+bzr6593-1ubuntu1.5) but 2.6.0+bzr6593-1ubuntu1.1 is installed
 python-samba : Depends: samba-libs (= 2:4.1.6+dfsg-1ubuntu2.14.04.9) but 2:4.1.6+dfsg-1ubuntu2.14.04.11 is installed
 python3-uno : Depends: libreoffice-core (= 1:4.2.8-0ubuntu2) but 1:4.2.8-0ubuntu3 is installed
E: Unmet dependencies. Try using -f.

编辑:

$ apt-cache policy apport-gtk python3-apport bzr python-bzrlib python-samba samba-libs python3-uno libreoffice-core
apport-gtk:
  Installed: 2.14.1-0ubuntu3.19
  Candidate: 2.14.1-0ubuntu3.19
  Version table:
 *** 2.14.1-0ubuntu3.19 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.14.1-0ubuntu3.18 0
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
     2.14.1-0ubuntu3 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
python3-apport:
  Installed: 2.14.1-0ubuntu3.18
  Candidate: 2.14.1-0ubuntu3.19
  Version table:
     2.14.1-0ubuntu3.19 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
 *** 2.14.1-0ubuntu3.18 0
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2.14.1-0ubuntu3 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
bzr:
  Installed: 2.6.0+bzr6593-1ubuntu1.5
  Candidate: 2.6.0+bzr6593-1ubuntu1.5
  Version table:
 *** 2.6.0+bzr6593-1ubuntu1.5 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.6.0+bzr6593-1ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
python-bzrlib:
  Installed: 2.6.0+bzr6593-1ubuntu1.1
  Candidate: 2.6.0+bzr6593-1ubuntu1.5
  Version table:
     2.6.0+bzr6593-1ubuntu1.5 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
 *** 2.6.0+bzr6593-1ubuntu1.1 0
        100 /var/lib/dpkg/status
     2.6.0+bzr6593-1ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
python-samba:
  Installed: 2:4.1.6+dfsg-1ubuntu2.14.04.9
  Candidate: 2:4.1.6+dfsg-1ubuntu2.14.04.11
  Version table:
     2:4.1.6+dfsg-1ubuntu2.14.04.11 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
 *** 2:4.1.6+dfsg-1ubuntu2.14.04.9 0
        100 /var/lib/dpkg/status
     2:4.1.6+dfsg-1ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
samba-libs:
  Installed: 2:4.1.6+dfsg-1ubuntu2.14.04.11
  Candidate: 2:4.1.6+dfsg-1ubuntu2.14.04.11
  Version table:
 *** 2:4.1.6+dfsg-1ubuntu2.14.04.11 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2:4.1.6+dfsg-1ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
python3-uno:
  Installed: 1:4.2.8-0ubuntu2
  Candidate: 1:4.2.8-0ubuntu3
  Version table:
     1:4.2.8-0ubuntu3 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
 *** 1:4.2.8-0ubuntu2 0
        100 /var/lib/dpkg/status
     1:4.2.3~rc3-0ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
libreoffice-core:
  Installed: 1:4.2.8-0ubuntu3
  Candidate: 1:4.2.8-0ubuntu3
  Version table:
 *** 1:4.2.8-0ubuntu3 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
        100 /var/lib/dpkg/status
     1:4.2.3~rc3-0ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

输出

$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  kde-l10n-engb linux-headers-3.19.0-25 linux-headers-3.19.0-25-generic
  linux-headers-3.19.0-26 linux-headers-3.19.0-26-generic
  linux-image-3.19.0-25-generic linux-image-3.19.0-26-generic
  linux-image-extra-3.19.0-25-generic linux-image-extra-3.19.0-26-generic
  linux-signed-image-3.19.0-26-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  python-apt python-bzrlib python-libxml2 python-samba
  python-software-properties python3-apport python3-apt
  python3-software-properties python3-uno software-properties-common
  software-properties-gtk
Suggested packages:
  python-apt-dbg python-vte python-apt-doc python-bzrlib-dbg
  python-bzrlib.tests python-kerberos python3-launchpadlib python3-apt-dbg
The following packages will be upgraded:
  python-apt python-bzrlib python-libxml2 python-samba
  python-software-properties python3-apport python3-apt
  python3-software-properties python3-uno software-properties-common
  software-properties-gtk
11 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
23 not fully installed or removed.
Need to get 0 B/3,127 kB of archives.
After this operation, 2,048 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 349631 files and directories currently installed.)
Preparing to unpack .../python-samba_2%3a4.1.6+dfsg-1ubuntu2.14.04.11_amd64.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing archive /var/cache/apt/archives/python-samba_2%3a4.1.6+dfsg-1ubuntu2.14.04.11_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../python3-apt_0.9.3.5ubuntu2_amd64.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error processing archive /var/cache/apt/archives/python3-apt_0.9.3.5ubuntu2_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
Preparing to unpack .../python3-apport_2.14.1-0ubuntu3.19_all.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error processing archive /var/cache/apt/archives/python3-apport_2.14.1-0ubuntu3.19_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
Preparing to unpack .../python-bzrlib_2.6.0+bzr6593-1ubuntu1.5_amd64.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing archive /var/cache/apt/archives/python-bzrlib_2.6.0+bzr6593-1ubuntu1.5_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../python-apt_0.9.3.5ubuntu2_amd64.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing archive /var/cache/apt/archives/python-apt_0.9.3.5ubuntu2_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../python-libxml2_2.9.1+dfsg1-3ubuntu4.7_amd64.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing archive /var/cache/apt/archives/python-libxml2_2.9.1+dfsg1-3ubuntu4.7_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../software-properties-gtk_0.92.37.7_all.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
No apport report written because MaxReports is reached already
                                                              dpkg: error processing archive /var/cache/apt/archives/software-properties-gtk_0.92.37.7_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
Preparing to unpack .../software-properties-common_0.92.37.7_all.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
No apport report written because MaxReports is reached already
                                                              dpkg: error processing archive /var/cache/apt/archives/software-properties-common_0.92.37.7_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
Preparing to unpack .../python3-software-properties_0.92.37.7_all.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error processing archive /var/cache/apt/archives/python3-software-properties_0.92.37.7_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
No apport report written because MaxReports is reached already
                                                              Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
Preparing to unpack .../python-software-properties_0.92.37.7_all.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing archive /var/cache/apt/archives/python-software-properties_0.92.37.7_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../python3-uno_1%3a4.2.8-0ubuntu3_amd64.deb ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
No apport report written because MaxReports is reached already
                                                              dpkg: error processing archive /var/cache/apt/archives/python3-uno_1%3a4.2.8-0ubuntu3_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
Errors were encountered while processing:
 /var/cache/apt/archives/python-samba_2%3a4.1.6+dfsg-1ubuntu2.14.04.11_amd64.deb
 /var/cache/apt/archives/python3-apt_0.9.3.5ubuntu2_amd64.deb
 /var/cache/apt/archives/python3-apport_2.14.1-0ubuntu3.19_all.deb
 /var/cache/apt/archives/python-bzrlib_2.6.0+bzr6593-1ubuntu1.5_amd64.deb
 /var/cache/apt/archives/python-apt_0.9.3.5ubuntu2_amd64.deb
 /var/cache/apt/archives/python-libxml2_2.9.1+dfsg1-3ubuntu4.7_amd64.deb
 /var/cache/apt/archives/software-properties-gtk_0.92.37.7_all.deb
 /var/cache/apt/archives/software-properties-common_0.92.37.7_all.deb
 /var/cache/apt/archives/python3-software-properties_0.92.37.7_all.deb
 /var/cache/apt/archives/python-software-properties_0.92.37.7_all.deb
 /var/cache/apt/archives/python3-uno_1%3a4.2.8-0ubuntu3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

相关内容