9

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?

user43704
  • 268
  • 3
  • 6
  • I'm not sure what would cause this, but one idea would be to delete the locally installed packages from `/usr/local/lib/python3.4/dist-packages` (or move them out of the way) and try again. – Josh Kelley Jan 24 '17 at 13:38
  • I typically recommend to NOT install via `sudo pip` or `sudo pip3` on a Linux distro. The advantage of a Linux distro is that the distro package manager (APT for Ubuntu) is managing software and updates for you, and you lose a lot of that if you start `sudo pip` (or `sudo make install`, etc.) yourself. Instead, I suggest sticking with distro-provided Python packages or using virtualenv to install what you need. That way, if a virtualenv gets messed up, it's trivial to deactivate and delete it and start over. – Josh Kelley Jan 24 '17 at 13:39

5 Answers5

16

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.

ThirstyLeopard
  • 184
  • 1
  • 6
  • 3
    that fixed it for me as well, just change `MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")` to `MARKER_EXPR = originalTextFor(MARKER_EXPR(""))("marker")` – Aly Shmahell Apr 14 '17 at 09:51
5

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.

Cerin
  • 60,957
  • 96
  • 316
  • 522
0

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

Kehe CAI
  • 1,161
  • 12
  • 18
  • I was getting this error from `update-manager` on Ubuntu Trusty. I was able to `sudo -H pip3 install pyparsing --upgrade` to get a new version which didn't throw a TypeError. – leftiness Mar 23 '17 at 16:01
0

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.

brbcoffee
  • 85
  • 5
0

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.

Community
  • 1
  • 1