Why is PIP raising an AssertionError on pip freeze?

前端 未结 7 505
耶瑟儿~
耶瑟儿~ 2020-12-14 14:32

My console:

desarrollador@desarrollador-HP-14-Notebook-PC1:~$ pip freeze  
Exception:  
Traceback (most recent call last):  
  File \"/usr/lib/python2.7/dist         


        
相关标签:
7条回答
  • 2020-12-14 15:05

    Reason: The python-pip package in Ubuntu 12.04 is seriously outdated and has some bugs with certain package names (as I can see) and cannot parse them correctly.

    Solution: install a newer version of pip, via easy_install.

    0 讨论(0)
  • 2020-12-14 15:11

    The problem is due to an old version of pip being installed. Run the following command to install a new version of pip:

    sudo easy_install -U pip. 
    
    0 讨论(0)
  • 2020-12-14 15:12

    It may be a bit late, but one thing I found was there are 2 or three versions of pip installed (depending on what you installed)

    pip - the OS version installed, freeze doesn't work and it can be out of date pip2 - the newer one installed but upgrading pip via pip etc pip3 - installed if you have python3 and python2 installed at the same time.

    You can either change which pip gets used in $PATH, or do what I did:

    pip2 freeze (which does work on ubuntu14 if you have more than one option for python)

    0 讨论(0)
  • 2020-12-14 15:14

    First, I ran Martin Mohan's solution:

    /usr/local/bin/pip uninstall pip
    apt-get remove python-pip
    apt-get install python-pip
    

    Then, boredcoding's ultimately fixed the problem, both solutions are found near bottom of thread: I screwed up the system version of Python Pip on Ubuntu 12.10

    $apt-get install python-pip
    $which pip
    /usr/bin/pip
    
    $pip install -U pip
    $which pip
    /usr/bin/pip
    
    $hash -r
    $which pip
    /usr/local/bin/pip
    

    The logic behind these two fix are stated in the thread (linked above), so I will refrain from going into each here.

    0 讨论(0)
  • 2020-12-14 15:20

    This worked for me (running Ubuntu, both 12 and 14 LTS):

    pip install -U setuptools
    pip install -U pip
    

    Upgrade to the latest version of setuptools in order to be able to upgrade to the latest version of pip, and upgrade to the latest version of pip to get a version that has fixed the AssertException error.

    0 讨论(0)
  • 2020-12-14 15:28

    Your pip may be outdated. Even in Ubuntu 14.04 LTS, the pip version it installed using apt-get install python-pip was 1.5.4. Try updating pip manually, and possibly the new packages again as well.

    pip --version # 1.5.4
    curl -O https://bootstrap.pypa.io/get-pip.py
    sudo python get-pip.py
    pip --version # 6.0.8
    hash -r # reset bash cache
    

    https://pip.pypa.io/en/latest/installing.html

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