Error after upgrading pip: cannot import name 'main'

后端 未结 30 1990
清歌不尽
清歌不尽 2020-11-22 15:51

Whenever I am trying to install any package using pip, I am getting this import error:

guru@guru-notebook:~$ pip3 install numpy
Traceback (most recent call l         


        
30条回答
  •  -上瘾入骨i
    2020-11-22 16:12

    For what it's worth, I had the problem with pip (not pip2 or pip3):

    $ pip -V
    Traceback (most recent call last):
      File "/usr/bin/pip", line 9, in 
        from pip import main
    ImportError: cannot import name main
    
    $ pip2 -V
    pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
    
    $ pip3 -V
    pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
    

    Somehow (I can't remember how) I had python stuff installed in my ~/.local directory. After I removed the pip directory from there, pip started working again.

    $ rm -rf /home/precor/.local/lib/python2.7/site-packages/pip
    $ pip -V
    pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
    

提交回复
热议问题