How to fix pip being proken after installing line_

2019-04-06 17:43发布

Using Ubuntu 14.04.5 LTS. Tried to install line_profiler with sudo pip3 install line_profiler, and now when I run sudo pip3, I get the following output:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 72, in <module>
    import packaging.requirements
  File "/usr/local/lib/python3.4/dist-packages/packaging/requirements.py", line 59, in <module>
    MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() missing 1 required positional argument: 'name'

Get a similar error when I try to run a django application now, so I guess a lot of stuff is messed up.

Anyone have any idea of what could have went wrong or how to fix?

标签: python linux pip
5条回答
仙女界的扛把子
2楼-- · 2019-04-06 18:18

I encountered this myself and reported it as a bug in packaging, but a maintainer explained that this is due to an outdated version of pyparsing. Upgrading to pyparsing>=2.0.2 should fix the error.

查看更多
做个烂人
3楼-- · 2019-04-06 18:21

I've just encountered the same error on a relatively fresh Ubuntu 14.04 config after installing just a couple packages. I'm guessing buggy code has been pushed to a repository.

Look at the root cause of the exception:

  File "/usr/local/lib/python3.4/dist-packages/packaging/requirements.py", line 59, in <module>
    MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() missing 1 required positional argument: 'name'

The problem is that the MARKER_EXPR() call should have a 'name' argument but it doesn't. My fix was to edit the requirements.py file such that it contained MARKER_EXPR(""). This solved it for me.

查看更多
Anthone
4楼-- · 2019-04-06 18:30

Similar problem (line-profiler broke pip), but different error.

Solved (thanks to Josh's comment) by deleting some locally installed packages (falling back to the OS-provided defaults) and then updating:

sudo rm -rf /usr/local/lib/python3.4/dist-packages/setuptools*
sudo rm -rf /usr/local/lib/python3.4/dist-packages/pkg_resources
sudo pip3 install --upgrade pip

Warning: this command will delete files without asking. YMMV so backup those files first.

查看更多
别忘想泡老子
5楼-- · 2019-04-06 18:38

Accepted answer worked for me. However, as noted in another answer, pyparsing needed updating. After adding the quotes in requirements.py, I was able to upgrade pyparsing. I then removed my edit, and pip continued functioning correctly.

查看更多
可以哭但决不认输i
6楼-- · 2019-04-06 18:42

just do sudo pip uninstall pyparsing, afterward sudo pip install pyparsing, then every thing will be ok.

查看更多
登录 后发表回答