ModuleNotFoundError: No module named 'pip.download' when trying to install Python package for Django

ModuleNotFoundError: No module named 'pip.download' when trying to install Python package for Django

尝试使用 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/

如果您希望使用此代码 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

(源自类似的答案:)

pip 版本应该降到 9.0.1 pip install pip==9.0.1