Matplotlib requires pyparsing

I am trying to build some data using matplotlib. When importing a library, I get an error:

ImportError: matplotlib requires pyparsing 

I installed pyparsing with easy_install pyparsing , but the error continues to appear.

How can I solve this problem? Alternatively, is there an alternative to matplotlib for creating stuff using Python?

Edit: sys.path returns:

 ['', 'C:\\Python27\\lib\\site-packages\\spyderlib\\utils\\external', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\lib\\site-packages\\Orange\\orng', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode', 'C:\\Python27\\lib\\site-packages\\IPython\\extensions'] 

Attempting to import pyparsing returns an error:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile execfile(filename, namespace) File "C:/Python27/Lib/site-packages/xy/simulation.py", line 4, in <module> import pyparsing ImportError: No module named pyparsing 
+6
source share
5 answers

What are you standing for, you can also try installing through pip if you have one. Quick link if you need to install the script: fooobar.com/questions/426 / .... Anyway, just use:

 pip install pyparsing 
+7
source

Our conversation was long, so this answer will try to explain what I'm looking for, and hopefully helps you find a solution.

When you print your sys.path, which lists all the directories in which Python (in your case it looks like you are using the Spyder development environment) tries to find the modules upon import. You mentioned that when installing pyparsing, he mentioned the path "C: \ Python27 \ lib \ etc", which is most likely where he places the configuration information, not the actual pyparsing code. Either check the easy_install output more for another directory, or use Windows Search to find "pyparsing.py". The directory where the file is located should be in the python path (sys.path).

I installed pyparsing only now on my local computer, and the third - last line says: "Installed d: \ python27 \ lib \ site-packages \ pyparsing-2.0.1-py2.7.egg"

When I use Windows Explorer, I see that pyparsing exists in "D: \ Python27 \ Lib \ site-packages", which is in my sys.path, so it imports. It is possible that pyparsing is being installed in a strange place.

As a hack, you can try adding the path to your sys.path by doing:

 import sys sys.path.append("this\is\the\path") import pyparsing 

But you have to do it only at one time. For future use, you must really find out why it is installed in a place that python does not see by default. Perhaps Spyder is doing something funky; he has no idea.

+3
source
 apt-get remove python-pip apt-get install build-essential libssl-dev libffi-dev python-dev wget https://bootstrap.pypa.io/get-pip.py python get-pip.py apt-get install python-pip pip install cffi 

These steps resolved the main pip -version errors

+3
source

For me, the previous egg setting screwed things up. I just did:

 pip uninstall pyparsing pip install pyparsing 

And that fixed dependency resolution.

+2
source
 pip install pyparsing 

Did NOT work for me. pyparsing should come with python. Reinstalling python and pip worked for me.

0
source

All Articles