How to solve ValueError: bad marshal data when importing matplotlib
This error occurred when I was trying to run a .py to plot my graphs using matplotlib for the research. I was able to plot graphs well before this happened. However it wasted my precious few hours dedicated to research work so I want to spare your time and thought of writing how I solved... When I googled the error it said that it was an error in .pyc files but was not specific. I tried the given solutions like reinstalling python. (not reinstalling OS which was given as solution too since uninstalling python would cause OS errors)
The method I tried to remove .pyc files -> here
The error again was ->
Traceback (most recent call last):
File "2m.py", line 2, in <module>
import matplotlib.pyplot as plt
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 123, in <module>
import pyparsing
ValueError: bad marshal data (string ref out of range)
Then I tried installing pyparsing which was already installed. So I uninstalled and reinstalled again.
sudo apt-get remove python-pyparsing
sudo apt-get install python-pyparsing
Then the following error occurred:
Traceback (most recent call last):
File "2m-over-time.py", line 2, in <module>
import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot
As suggested above, I installed python-matplotlib again.
sudo apt-get install python-matplotlib
This was the easiest solution and I could get back to my actual work of plotting graphs with data collected! Hope it works for you too! :)
The method I tried to remove .pyc files -> here
The error again was ->
Traceback (most recent call last):
File "2m.py", line 2, in <module>
import matplotlib.pyplot as plt
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 123, in <module>
import pyparsing
ValueError: bad marshal data (string ref out of range)
Then I tried installing pyparsing which was already installed. So I uninstalled and reinstalled again.
sudo apt-get remove python-pyparsing
sudo apt-get install python-pyparsing
Then the following error occurred:
Traceback (most recent call last):
File "2m-over-time.py", line 2, in <module>
import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot
As suggested above, I installed python-matplotlib again.
sudo apt-get install python-matplotlib
This was the easiest solution and I could get back to my actual work of plotting graphs with data collected! Hope it works for you too! :)
Comments
Post a Comment