Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I do pip --version it show the error as ImportError: No module named pyparsing

I tried installing/uninstalling pyparsing as well and it does not work. I am stuck with this and I have to install additional libraries as well.

Here is the error message:

Traceback (most recent call last): 
File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
File "/home/rachana/.local/lib/python2.7/site-packages/pkg_resour‌​ces/__init__.py", line 72, in <module>
    import packaging.requirements
File "/home/rachana/.local/lib/python2.7/site-packages/packaging/‌​requirements.py", line 9, in <module>
    from pyparsing import stringStart, stringEnd, originalTextFor, ParseException
ImportError: No module named pyparsing

How can I fix this?

like image 471
rachana_sharma003 Avatar asked Feb 11 '17 20:02

rachana_sharma003


People also ask

How do I fix No module named Pip?

The Python "ModuleNotFoundError: No module named 'pip'" occurs when pip is not installed in our Python environment. To solve the error, install the module by running the python -m ensurepip --upgrade command on Linux or MacOS or py -m ensurepip --upgrade on Windows.

How do I fix No module named typing?

The Python "ImportError: No module named 'typing'" occurs when we use an outdated version of pip . To solve the error, run the python -m pip install --upgrade pip command and install the typing module by running pip install typing .

How do I know if Pyparsing is installed?

Method 1: pip show. To check which version of the Python library pyparsing is installed, run pip show pyparsing or pip3 show pyparsing in your CMD/Powershell (Windows), or terminal (macOS/Linux/Ubuntu).

What is Pyparsing in Python?

The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the traditional lex/yacc approach, or the use of regular expressions. The pyparsing module provides a library of classes that client code uses to construct the grammar directly in Python code.


1 Answers

I'm had the same problem and resolved it. Here is you can see that pip not working properly (without any additional parameters).

root@notebook:/home/ci# pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 72, in <module>
    import packaging.requirements
  File "/usr/local/lib/python2.7/dist-packages/packaging/requirements.py", line 9, in <module>
    from pyparsing import stringStart, stringEnd, originalTextFor, ParseException

Okay, so first that we may do is installing broken dependency:

wget https://pypi.python.org/packages/3c/ec/a94f8cf7274ea60b5413df054f82a8980523efd712ec55a59e7c3357cf7c/pyparsing-2.2.0.tar.gz
gunzip pyparsing-2.2.0.tar.gz
tar -xvf pyparsing-2.2.0.tar
cd pyparsing-2.2.0 && python setup.py install

After it mising dependency will be installed from sources.

Trying to using pip one more time:

[email protected]:/tmp/pyparsing-2.2.0# pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 74, in <module>
    import appdirs
ImportError: No module named appdirs

This is the next problem. And you can fix it more quickly:

root@notebook:/home/ci# python -m pip install appdirs
Downloading/unpacking appdirs
  Downloading appdirs-1.4.3-py2.py3-none-any.whl
Installing collected packages: appdirs
Successfully installed appdirs
Cleaning up...

After that my pip was successfully repaired. Kind regards.

like image 150
Oleg Mykolaichenko Avatar answered Oct 16 '22 04:10

Oleg Mykolaichenko