【问题标题】:How to install pip on debian with python 2.7?如何使用 python 2.7 在 debian 上安装 pip?
【发布时间】:2018-03-15 14:47:38
【问题描述】:

我阅读了许多网站和问答,但我总是遇到同样的错误,而且我找不到解决方案。 我的错误:

处理时的错误: python error python-crypto python-wheel python-pkg-resources python-keyrings.alt ptho-dbus python-pip python-xdg python-secretstorage python-keyring E:Sub-process /usr/bin/dpkg returned an error code(1).

我将 Python 2.7.13 安装到 /usr/src/Python2.7.13

有什么想法吗?

编辑 - Beomi:

sudo apt-get update   -- done, working
sudo apt-get upgrade  -- not working, i get the errors what i wrote
sudo apt-get -f install -- not working, i get the errors what i wrote

我通过以下链接安装了 Python 2.7.13:https://tecadmin.net/install-python-2-7-on-ubuntu-and-linuxmint/#

Edit2 - Beomi:

web@debian:/usr/src/Python-2.7.13$ sudo dpkg --configure -a
Beállítás: python-crypto (2.6.1-7) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 26, in <module>
    import logging
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
dpkg: error processing package python-crypto (--configure):
 installed post-installation script alfolyamat 1 hibakóddal kilépett
Beállítás: python-wheel (0.29.0-2) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 26, in <module>
    import logging
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
dpkg: error processing package python-wheel (--configure):
 installed post-installation script alfolyamat 1 hibakóddal kilépett
dpkg: error processing package python-pkg-resources (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of python-keyrings.alt:
 python-keyrings.alt függőségek: python-crypto; ám:
  python-crypto csomag még beállítatlan.

dpkg: error processing package python-keyrings.alt (--configure):
 függőségi hibák - e csomag beállítatlan maradt
Beállítás: python-dbus (1.2.4-1+b1) ...
Remove stale byte-compiled files...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 26, in <module>
    import logging
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
dpkg: error processing package python-dbus (--configure):
 installed post-installation script alfolyamat 1 hibakóddal kilépett
Beállítás: python-pip (9.0.1-2) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 26, in <module>
    import logging
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
dpkg: error processing package python-pip (--configure):
 installed post-installation script alfolyamat 1 hibakóddal kilépett
Beállítás: python-xdg (0.25-4) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 26, in <module>
    import logging
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
dpkg: error processing package python-xdg (--configure):
 installed post-installation script alfolyamat 1 hibakóddal kilépett
dpkg: dependency problems prevent configuration of python-secretstorage:
 python-secretstorage függőségek: python-dbus; ám:
  python-dbus csomag még beállítatlan.

dpkg: error processing package python-secretstorage (--configure):
 függőségi hibák - e csomag beállítatlan maradt
dpkg: dependency problems prevent configuration of python-keyring:
 python-keyring függőségek: python-dbus; ám:
  python-dbus csomag még beállítatlan.
 python-keyring függőségek: python-secretstorage; ám:
  python-secretstorage csomag még beállítatlan.

dpkg: error processing package python-keyring (--configure):
 függőségi hibák - e csomag beállítatlan maradt
Hibák történtek a feldolgozáskor:
 python-crypto
 python-wheel
 python-pkg-resources
 python-keyrings.alt
 python-dbus
 python-pip
 python-xdg
 python-secretstorage
 python-keyring

【问题讨论】:

    标签: python pip debian virtualbox setuptools


    【解决方案1】:

    由于您的问题不包括您到目前为止所做的事情..

    那么,先修复你的 apt 包怎么样?

    试试这个:

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get -f install
    

    然后使用sudo 重试。

    还有一个:用sudo apt-get install python安装python怎么样?

    如果你真的需要最新版本的python 2.7,请在问题/评论中告诉。

    如果不起作用,请更新问题和评论。

    -- 更新--

    由于sudo apt-get upgrade不工作,我认为PATH会有问题,系统默认python vs新安装的python。

    -- 更新--

    可能是debian iso文件的问题。

    【讨论】:

    • 哪个 python : 我明白了 --> /usr/bin/python
    • 所以当你执行python时,它是系统默认的python,而不是你安装的python。让我再想一想……
    • 你能告诉我sudo dpkg --configure -a的结果吗?
    • 你会试试sudo apt-get install --reinstall python2.7 吗?此命令将安装带有纯的python2.7。
    【解决方案2】:

    就用这个

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install python-pip
    

    查看此link 了解更多信息

    编辑:

    也检查This。了解这一点很重要。

    编辑: 试试这个 (src)

    sudo apt-get install python-pip
    

    还有这个 (src)

    $ curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
    
    $ python get-pip.py  
    

    【讨论】:

    • 链接显示 警告最近的 Debian/Ubuntu 版本已将 pip 修改为默认使用“用户方案”,这是一个重大的行为变化,可能会让一些用户感到惊讶
    • 我必须尝试哪一部分?
    • 或者试试这个:sudo apt-get install python-pip
    • sudo apt-get install python-pip :我得到同样的错误; curl "bootstrap.pypa.io/get-pip.py" -o "get-pip.py" :没有 curl,所以我尝试使用 sudo wget,但在运行 get-pip.py 后,我得到语法错误...大声笑..
    • 那么我建议通过第二个链接。有可能的安装方式。或者下载它并运行安装程序。这是最后一条评论。
    【解决方案3】:

    python 2.7 中有一个名为 get_pip.py 的文件,你可以运行它并检查一下吗?目标机器上的python get_pip.py。

    【讨论】:

    • 不,没有
    【解决方案4】:

    简单

    sudo apt-get install libssl-dev &&
    wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz &&
    tar -xvf Python-2.7.13.tar.xz &&
    cd Python-2.7.13 &&
    ./configure && sudo make && sudo make install
    

    【讨论】:

    • 不只是这样。我也尝试过这种方法,但我得到了同样的错误信息。 :(
    • 尝试purging python 并再次安装
    • 使用 'sudo apt-get remove python2.7' ?
    • apt-get purge python 但很危险!
    • 我试过这个:sudo apt-get purge --auto-remove python-debian 但结果又是同样的错误信息......
    猜你喜欢
    • 2011-10-19
    • 1970-01-01
    • 2023-03-21
    • 2019-06-13
    • 2017-11-06
    • 2014-12-22
    • 1970-01-01
    • 2013-12-25
    • 1970-01-01
    相关资源
    最近更新 更多