ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source'

后端 未结 5 1230
悲&欢浪女
悲&欢浪女 2020-12-02 00:50

pip3 install is not working and also pip3 is not being able to downgrade to pip19 from pip20.0:

Rayaans-MacBook-Pro:~ rayaangrewal$ pip3 install         


        
相关标签:
5条回答
  • 2020-12-02 01:25

    under project name go to following file in virtual enviroment. venv\Lib\site-packages\pip_internal\distributions__init__.py comment out the very first line which reads.

    from pip._internal.distributions.source import SourceDistribution

    then install pip version desired.

    0 讨论(0)
  • 2020-12-02 01:29

    curl https://bootstrap.pypa.io/get-pip.py | sudo python3

    The above fix fixed the issue for me

    0 讨论(0)
  • 2020-12-02 01:34

    Install a new version of pip fixes it:

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    python get-pip.py
    
    0 讨论(0)
  • 2020-12-02 01:44

    Good answers in @pdh's link to github issues.

    When using venv in Python 3.6+ on Ubuntu/LXC with a self-install/self-upgrading pip command during execution, you can use get-pip.py instead:

    1. Activate the virtual environment venv: source bin/activate

    2. Now, instead of the self-updating pip command (which does not work in pip 0.20.0): bin/pip3 install --upgrade pip

    3. You can use:

    cd bin
    # downloading get-pip.py each time; but you could also remove it from here
    # and run this manually only once:
    wget https://bootstrap.pypa.io/get-pip.py -O ./get-pip.py
    # definitely keep this command:
    python3 get-pip.py
    cd ..
    

    Result:

    Collecting pip
    ...
    Installing collected packages: pip
      Found existing installation: pip 20.0.0
        Uninstalling pip-20.0.0:
          Successfully uninstalled pip-20.0.0
    Successfully installed pip-20.0.1
    

    Notes to get-pip.py:

    • It will upgrade all existing pip applications in that /bin folder (e.g. pip, pip3, pip3.6)
    • It will inherently use the arguments install, --upgrade, --force-reinstall
    • It uses the arguments setuptools and wheel by default unless specifically disabled with --no-setuptools or --no-wheel

    GET-PIP.PY WARNING

    In light of the friendly error message WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly., one can instead replace point 3. above with:

    bin/python3 -m pip install -U pip [setuptools] [wheel] [--no-cache-dir]
    
    0 讨论(0)
  • 2020-12-02 01:48

    This is a bug in pip 20.0; see https://github.com/pypa/pip/issues/7620

    It's fixed in pip 20.0.1. Upgrade to 20.0.1+ or downgrade to 19.3.1. Get get-pip.py and run

    python get-pip.py
    

    or

    python get-pip.py pip==19.3.1
    
    0 讨论(0)
提交回复
热议问题