Ubuntu 16.04(AWS EC2)上的python依赖关系被破坏

Ubuntu 16.04(AWS EC2)上的python依赖关系被破坏,python,linux,python-3.x,dependencies,ubuntu-16.04,Python,Linux,Python 3.x,Dependencies,Ubuntu 16.04,我试图删除Ubuntu 16.04上安装的所有python。现在,我明白我不应该这么做。然而,仅仅尝试重新安装python是行不通的 当我尝试 $ sudo apt install -f --reinstall python3 Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: python3-doc python

我试图删除Ubuntu 16.04上安装的所有python。现在,我明白我不应该这么做。然而,仅仅尝试重新安装python是行不通的

当我尝试

$ sudo apt install -f --reinstall python3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  python3-doc python3-tk python3-venv
The following NEW packages will be installed:
  python3
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 0 B/8,710 B of archives.
After this operation, 68.6 kB of additional disk space will be used.
Setting up python3.5-minimal (3.5.2-2ubuntu0~16.04.5) ...
# Empty sitecustomize.py to avoid a dangling symlink
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

Current thread 0x00007fc6b52dd700 (most recent call first):
Aborted
dpkg: error processing package python3.5-minimal (--configure):
 subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of python3-minimal:
 python3-minimal depends on python3.5-minimal (>= 3.5.1-2~); however:
  Package python3.5-minimal is not configured yet.

dpkg: error processing package python3-minimal (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python3.5-minimal
 python3-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

$ python3
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

Current thread 0x00007f87215c4700 (most recent call first):
Aborted

我尝试过不同的事情,但在这一点上,我不知道如何解决这个问题

$ sudo apt-get -f install dh-python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
dh-python is already the newest version (2.20151103ubuntu1.1).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 dh-python : Depends: python3:any (>= 3.3.2-2~)
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

也许从带有
sudodpkg-i
的deb包安装python是一个更好的主意?您可以下载它,例如

也许从带有
sudodpkg-i
的deb包中安装python是一个更好的主意?您可以下载它,例如

您应该尝试:
sudo-apt-get-update

然后尝试使用下面的命令卸载python

sudo apt purge python3.x-minimal

如果卸载成功,则

sudo apt get install python3.6

您应该尝试:
sudo-apt-get-update

然后尝试使用下面的命令卸载python

sudo apt purge python3.x-minimal

如果卸载成功,则


sudo-apt-get-install-python3.6

在ubuntu从16升级到18之后,我遇到了类似的python3问题。但是你可以试着用我16号的解题法。只需针对
apt

注意:我需要在我的系统中安装python2.7

我遵循这些步骤:

  • 卸载所有python3软件包:

    sudo-apt-remove-python3&&sudo-apt-autoremove

  • 但这对我没有帮助。因此,将尝试定义系统中仍存在哪些包:

    apt列表--已安装| grep python*

    //possible output:
    WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    libpython-stdlib/bionic,now 2.7.15~rc1-1 amd64 [installed,automatic]
    libpython2.7-minimal/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    libpython2.7-stdlib/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    libpython3-stdlib/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
    libpython3.5/now 3.5.2-2ubuntu0~16.04.12 amd64 [installed,local]
    libpython3.5-minimal/now 3.5.2-2ubuntu0~16.04.12 amd64 [installed,local]
    libpython3.5-stdlib/now 3.5.2-2ubuntu0~16.04.12 amd64 [installed,local]
    libpython3.6/bionic-updates,bionic-security,now 3.6.9-1~18.04ubuntu1.3 amd64 [installed,automatic]
    libpython3.6-minimal/bionic-updates,bionic-security,now 3.6.9-1~18.04ubuntu1.3 amd64 [installed,automatic]
    libpython3.6-stdlib/bionic-updates,bionic-security,now 3.6.9-1~18.04ubuntu1.3 amd64 [installed,automatic]
    python/bionic,now 2.7.15~rc1-1 amd64 [installed]
    python-apt-common/bionic-updates,bionic-updates,bionic-security,bionic-security,now 1.6.5ubuntu0.5 all [installed]
    python-minimal/bionic,now 2.7.15~rc1-1 amd64 [installed,automatic]
    python2.7/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    python2.7-minimal/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    
  • 正如我们所看到的,一些python3包在系统中。将删除它们

    sudo apt删除libpython3 stdlib libpython3.5 libpython3.5-minimal libpython3.5-stdlib libpython3.6 libpython3.6-minimal libpython3.6-stdlib

  • 现在,尝试安装python3

    sudo apt安装python3

  • 一切都会好起来的


  • 在ubuntu从16升级到18之后,我对python3也有类似的问题。但是你可以试着用我16号的解题法。只需针对
    apt

    注意:我需要在我的系统中安装python2.7

    我遵循这些步骤:

  • 卸载所有python3软件包:

    sudo-apt-remove-python3&&sudo-apt-autoremove

  • 但这对我没有帮助。因此,将尝试定义系统中仍存在哪些包:

    apt列表--已安装| grep python*

    //possible output:
    WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    libpython-stdlib/bionic,now 2.7.15~rc1-1 amd64 [installed,automatic]
    libpython2.7-minimal/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    libpython2.7-stdlib/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    libpython3-stdlib/bionic-updates,now 3.6.7-1~18.04 amd64 [installed]
    libpython3.5/now 3.5.2-2ubuntu0~16.04.12 amd64 [installed,local]
    libpython3.5-minimal/now 3.5.2-2ubuntu0~16.04.12 amd64 [installed,local]
    libpython3.5-stdlib/now 3.5.2-2ubuntu0~16.04.12 amd64 [installed,local]
    libpython3.6/bionic-updates,bionic-security,now 3.6.9-1~18.04ubuntu1.3 amd64 [installed,automatic]
    libpython3.6-minimal/bionic-updates,bionic-security,now 3.6.9-1~18.04ubuntu1.3 amd64 [installed,automatic]
    libpython3.6-stdlib/bionic-updates,bionic-security,now 3.6.9-1~18.04ubuntu1.3 amd64 [installed,automatic]
    python/bionic,now 2.7.15~rc1-1 amd64 [installed]
    python-apt-common/bionic-updates,bionic-updates,bionic-security,bionic-security,now 1.6.5ubuntu0.5 all [installed]
    python-minimal/bionic,now 2.7.15~rc1-1 amd64 [installed,automatic]
    python2.7/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    python2.7-minimal/bionic-updates,bionic-security,now 2.7.17-1~18.04ubuntu1.2 amd64 [installed,automatic]
    
  • 正如我们所看到的,一些python3包在系统中。将删除它们

    sudo apt删除libpython3 stdlib libpython3.5 libpython3.5-minimal libpython3.5-stdlib libpython3.6 libpython3.6-minimal libpython3.6-stdlib

  • 现在,尝试安装python3

    sudo apt安装python3

  • 一切都会好起来的


  • 嗨,谢谢。所以当我尝试卸载时<代码>$sudo apt purge python3.x-最小读取包列表。。。已完成构建依赖关系树以读取状态信息。。。完成E:找不到程序包python3.x-minimal E:找不到glob'python3.x-minimal'的任何程序包E:找不到regex'python3.x-minimal'的任何程序包您好,谢谢。所以当我尝试卸载时<代码>$sudo apt purge python3.x-最小读取包列表。。。已完成构建依赖关系树以读取状态信息。。。完成E:找不到程序包python3.x-minimal E:找不到glob'python3.x-minimal'的任何程序包E:找不到regex'python3.x-minimal'的任何程序包您好,谢谢,我如何获取?我正在开发一个虚拟服务器嗨,谢谢,请问我怎么才能拿到它?我正在虚拟服务器上工作,您可以使用
    wget
    下载文件。直接链接:,,哦,顺便说一句,它是针对Ubuntu 16.04+的。你用的是什么操作系统?是的,我用的是16.04。然而,我已经加载了它。我仍然遇到问题
    $sudo dpkg-I python3_3.5.1-3_amd64.deb dpkg:关于包含python3的python3_3.5.1-3_amd64.deb,预依赖问题:python3预依赖于python3 minimal(=3.5.1-3)python3 minimal已解压缩,但从未配置。dpkg:处理存档python3_3.5.1-3_amd64.deb(--install)时出错:预依赖问题-未安装python3在处理时遇到错误:python3_3.5.1-3_amd64.deb
    您好,谢谢,我如何获取?我正在开发一个虚拟服务器嗨,谢谢,请问我怎么才能拿到它?我正在虚拟服务器上工作,您可以使用
    wget
    下载文件。直接链接:,,哦,顺便说一句,它是针对Ubuntu 16.04+的。你用的是什么操作系统?是的,我用的是16.04。然而,我已经加载了它。我仍然遇到问题
    $sudo dpkg-I python3_3.5.1-3_amd64.deb dpkg:关于包含python3的python3_3.5.1-3_amd64.deb,预依赖问题:python3预依赖于python3 minimal(=3.5.1-3)python3 minimal已解压缩,但从未配置。dpkg:处理存档python3_3.5.1-3_amd64.deb(--install)时出错:预依赖项问题-在处理python3_3.5.1-3_amd64.deb时遇到未安装python3错误