I have installed matplotlib and of course its requirements Numpy and scipy on my pc but I get this error message when I import pylab:
>>> from matplotlib import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/pylab.py", line 230, in <module>
import matplotlib.finance
File "/anaconda/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/finance.py", line 36, in <module>
from matplotlib.dates import date2num
File "/anaconda/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/dates.py", line 137, in <module>
import matplotlib.ticker as ticker
File "anaconda/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "/anaconda/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: /anaconda/lib/python2.7/site-packages/matplotlib-1.4.x-py2.7-linux-x86_64.egg/matplotlib/_path.so: undefined symbol: PyUnicodeUCS2_AsEncodedString
As far as I remember it used to work but now I get error message. I even re-installed it but didn't help. How could I fix it?
It may be that you are missing:
import matplotlib as mpl
However, if that does not work. Reinstall the Anacoda distribution, then make sure you have numpy and scipy installed.
The top of your program is then:
import numpy as np
import scipy
import matplotlib as mpl
import pylab
Related
When I was trying to import matplotlib, I wrote
import matplotlib.pyplot as plt
in my code.
and this error occured.
Traceback (most recent call last):
File "C:\aiProjects\opencv\test.py", line 2, in <module>
import matplotlib.pyplot as plt
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: DLL load failed while importing _path: The specified module could not be found.
Process finished with exit code 1
I tried several ways such as reinstalling matplotlib and pasting new "Msvcp71.dll" and "Msvcr71.dll" files in my system folders. Anyways to solve this problem?
... reinstall the matplotlib python package with this argument --ignore-installed:
pip3 install matplotlib --user --ignore-installed
I am sorry for asking this question again, but I could not find any answer to my problem that helped me. I don't have much experience with python. I use python version 3.6.8 on Windows and I have already installed matplotlib, numpy and scipy. The 'pylab.py' file is also contained in the matplotlib folder. Edit: Using matplotlib.pyplot also doesn't work.
Edit: After some more trials I got the error that the module 'six.names" could not be found. The six package has been installed.
import pylab
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pylab
ModuleNotFoundError: No module named 'pylab'
import matplotlib.pyplot
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
import matplotlib.pyplot
File "C:\...\Python36-32\lib\matplotlib\pyplot.py", line 30, in <module>
from cycler import cycler
File "C:\...\Python36-32\lib\cycler\cycler.py", line 48, in <module>
from six.moves import zip, reduce
ModuleNotFoundError: No module named 'six.moves'
Per https://matplotlib.org/faq/usage_faq.html#matplotlib-pyplot-and-pylab-how-are-they-related, pylab is not recommended; you should use pyplot instead.
The correct way to import either is
import matplotlib.pyplot # use this
import matplotlib.pylab # only if you cannot avoid it
(pyplot and pylab are not standalone modules, but submodules of matplotlib.)
I am using pycharm for python in windows 8. I have installed the package matplotlib.
I am using python 2.7
when i do import matplotlib there is no error.
However if i do matplotlib.pyplot as plt i am getting this following errors:
Traceback (most recent call last):
File "C:/Users/PiyushSudip/PycharmProjects/myFirst/test1.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 18, in <module>
from axes import Axes, SubplotBase, subplot_class_factory
File "C:\Python27\lib\site-packages\matplotlib\axes\__init__.py", line 4, in <module>
from ._subplots import *
File "C:\Python27\lib\site-packages\matplotlib\axes\_subplots.py", line 10, in <module>
from matplotlib.axes._axes import Axes
File "C:\Python27\lib\site-packages\matplotlib\axes\_axes.py", line 18, in <module>
from matplotlib.cbook import _string_to_bool, mplDeprecation
ImportError: cannot import name _string_to_bool
can anyone help figure out what i am doing wrong?
http://matplotlib.org/users/installing.html#required-dependencies
There is a package called six which matplotlib depends on. Check to make sure it's installed, or install it from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#six
This site has packaged versions of many python modules which are easy to setup on windows, just download and run.
Also check the other dependencies to make sure you have them all, otherwise you might get another error for a different module
What I have understood since trying to fix this is that I installed matplotlib but python does not utilize it to plot something.
I encountered some error messages like this:
from matplotlib import pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/pyplot.py", line 28, in <module>
import matplotlib.colorbar
File "/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backend_bases.py", line 61, in <module>
import matplotlib.textpath as textpath
File "/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/textpath.py", line 15, in <module>
import matplotlib.font_manager as font_manager
File "/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/font_manager.py", line 58, in <module>
from matplotlib import ft2font
ImportError: dlopen(/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/ft2font.so, 2): Library not loaded: libfreetype.6.dylib
Referenced from: /Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.5-x86_64.egg/matplotlib/ft2font.so
Reason: image not found
I googled image not found error, matplotlib reinstall and etc... but nothing has worked.
Does this have something to do with version of os x? I am using yosemite.
Here information.
>>> import pkgutil
>>> package = pkgutil.get_loader("matplotlib")
>>> package.filename
'/usr/local/lib/python2.7/dist-packages/matplotlib'
>>>
So where your "matplotlib" ?
COPY :
/Users/changhyunahn/anaconda/lib/python2.7/site-packages/matplotlib-1.5.dev1-pāāāāy2.7-macosx-10.5-x86_64.egg
TO : /usr/local/lib/python2.7/site-packages/
OR TO:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/
i have python 3.2.3 on windows.
installed matplotlib
i'm trying to do this:
import matplotlib.pyplot as plt
i get this:
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
import matplotlib.pyplot as plt
File "E:\programs\python 3.2.3\lib\site-packages\matplotlib\pyplot.py", line 24, in <module>
import matplotlib.colorbar
File "E:\programs\python 3.2.3\lib\site-packages\matplotlib\colorbar.py", line 29, in <module>
import matplotlib.collections as collections
File "E:\programs\python 3.2.3\lib\site-packages\matplotlib\collections.py", line 23, in <module>
import matplotlib.backend_bases as backend_bases
File "E:\programs\python 3.2.3\lib\site-packages\matplotlib\backend_bases.py", line 50, in <module>
import matplotlib.textpath as textpath
File "E:\programs\python 3.2.3\lib\site-packages\matplotlib\textpath.py", line 5, in <module>
import urllib.request, urllib.parse, urllib.error
ImportError: No module named urllib.request
any idea?
You need to install urllib.
This is required by matplotlib
Look Install urllib from : https://pypi.python.org/pypi/urllib2_file/0.2.1
Or if you was instaled pip you can use sudo pip install urllib