ImportError: No module named pip

前端 未结 19 683
时光取名叫无心
时光取名叫无心 2020-12-04 06:56

OS: Mac OS X 10.7.5 Python Ver: 2.7.5

I have installed setuptools 1.0 with ez_setup.py from https://pypi.python.org/pypi/setuptools Then I download pip.1.4.1 pkg fr

相关标签:
19条回答
  • 2020-12-04 07:25

    With macOS 10.15 and Homebrew 2.1.6 I was getting this error with Python 3.7. I just needed to run:

    python3 -m ensurepip
    

    Now python3 -m pip works for me.

    0 讨论(0)
  • 2020-12-04 07:25

    On some kind of linux like ubuntu, first, do apt-get update and then try installing the python-pip package. without apt-get update, you might get error such as

    E: Unable to locate package python-pip

    1.Update :

    sudo apt-get update

    2.Install the pip package

    For python2

    sudo apt-get install python-pip

    or

    For python3

    sudo apt-get install python3-pip

    And done!

    0 讨论(0)
  • 2020-12-04 07:27

    I had the same problem. My solution:

    For Python 3

    sudo apt-get install python3-pip
    

    For Python 2

    sudo apt-get install python-pip
    
    0 讨论(0)
  • 2020-12-04 07:27

    I solved a similar error on Linux by setting PYTHONPATH to the site-packages location. This was after running python get-pip.py --prefix /home/chet/pip.

    [chet@rhel1 ~]$ ~/pip/bin/pip -V
    Traceback (most recent call last):
      File "/home/chet/pip/bin/pip", line 7, in <module>
        from pip import main
    ImportError: No module named pip
    
    [chet@rhel1 ~]$ export PYTHONPATH=/home/chet/pip/lib/python2.6/site-packages
    
    [chet@rhel1 ~]$ ~/pip/bin/pip -V
    pip 9.0.1 from /home/chet/pip/lib/python2.6/site-packages (python 2.6)
    
    0 讨论(0)
  • 2020-12-04 07:28

    I had a similar problem with virtualenv that had python3.8 while installing dependencies from requirements.txt file. I managed to get it to work by activating the virtualenv and then running the command python -m pip install -r requirements.txt and it worked.

    0 讨论(0)
  • 2020-12-04 07:29

    I just needed to replace pip with pip3 so I ended up running the command as follows: pip3 install matplotlib

    0 讨论(0)
提交回复
热议问题