Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix pip being proken after installing line_profiler?

Tags:

python

linux

pip

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?

like image 560
user43704 Avatar asked Jan 24 '17 13:01

user43704


People also ask

How do I fix a broken pip?

If pip is broken after an attempted upgrade to a newer version, try the following: Download get-pip.py and "Save As" the file using right-click. Open a command prompt as an administrator. cd to the path where you saved the file, in my case cd C:\Users\xyz\Downloads> then type python get-pip.py .

Why isn't pip install working?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.

How do I Intall pip?

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process. Voila!


2 Answers

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.

like image 155
ThirstyLeopard Avatar answered Sep 28 '22 02:09

ThirstyLeopard


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.

like image 20
Cerin Avatar answered Sep 28 '22 04:09

Cerin