如何使用python 2.7在debian上安装pip?

问题描述 投票:0回答:5

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

处理时出错:

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/#

编辑2 - 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
5个回答
1
投票

简单

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

1
投票

就用这个

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

查看此链接了解更多信息

编辑:

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

编辑: 试试这个(src

sudo apt-get install python-pip

还有这个(src

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

$ python get-pip.py  

0
投票

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


0
投票

因为你的问题不包括你到目前为止所做的事情..

那么,先修复你的 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 与新安装的 python 会有问题。

-- 更新 --

可能是 debian iso 文件的问题。


0
投票

这就是我在 Debian Bullseye 上的工作:

apt-get install python-dev
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python -
© www.soinside.com 2019 - 2024. All rights reserved.