ModuleNotFoundError:尝试为Django安装Python软件包时,没有名为“ pip.download”的模块

时间:2018-09-20 21:26:47

标签: python django python-3.x pip django-2.0

尝试使用pip安装Numpy和其他软件包时。我收到一条消息,说ModuleNotFoundError: No module named 'pip.download'。有人知道任何可能的解决方案吗?我目前在Python3上运行。我看过类似的问题,但似乎没有解决方案。例如。 "pip install unroll": "python setup.py egg_info" failed with error code 1

pip3 install 'django-numpy==1.0'
Collecting django-numpy==1.0
  Downloading https://files.pythonhosted.org/packages/a2/15/22ea119379010455ee91c3ee2f76da207fbd342f5277305da3ad660a0a13/django-numpy-1.0.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/pz/d28llk412ss8ptwv5znkhv1m0000gn/T/pip-install-kwd6b6us/django-numpy/setup.py", line 6, in <module>
        from pip.download import PipSession
    ModuleNotFoundError: No module named 'pip.download'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/pz/d28llk412ss8ptwv5znkhv1m0000gn/T/pip-install-kwd6b6us/django-numpy/

2 个答案:

答案 0 :(得分:0)

如果您希望使用此代码from pip.download import PipSession更新旧的Python程序包,则可以替换此代码段

try:  # pip >= 10
    from pip._internal.download import PipSession
except ImportError:  # pip <= 9.0.3
    from pip.download import PipSession

(来自类似的答案:https://stackoverflow.com/a/49867265/148585

答案 1 :(得分:0)

Pip版本应降至9.0.1 pip install pip==9.0.1