I compiled matplotlib on a mac running snow leopard only to find that when I import matplotlib.pyplot I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", line 6, in <module>
from matplotlib.figure import Figure, figaspect
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", line 18, in <module>
from axes import Axes, SubplotBase, subplot_class_factory
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py", line 12, in <module>
import matplotlib.axis as maxis
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py", line 10, in <module>
import matplotlib.font_manager as font_manager
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 52, in <module>
from matplotlib import ft2font
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so, 2): Symbol not found: _FT_Attach_File
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so
Expected in: dynamic lookup
How do I fix this?
Building matplotlib on OS X is notoriously fraught with problems linking to mismatched versions of libraries that can be in the system directories, /usr/local, /opt/local, what have you. That's why there is a README.osx file in the source distribution advising you to use the make.osx file provided in the distribution that fetches and compiles the libraries and builds matplotlib against the fetched copy.
Related
I'm trying to run my Python program and these are the modules I'm importing:
from tkinter import *
from functools import partial
import numpy as np import
matplotlib matplotlib.use("TkAgg")
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg
import FigureCanvasTkAgg, NavigationToolbar2Tk
I always end up with the following error message:
C:\Users\HP\anaconda3\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "ASRS.py", line 12, in <module>
from matplotlib.figure import Figure
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\figure.py", line 18, in <module>
from matplotlib import docstring, projections
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\projections\__init__.py", line 1, in <module>
from .. import axes, docstring
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\axes\__init__.py", line 1, in <module>
from ._subplots import *
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\axes\_subplots.py", line 6, in <module>
from matplotlib.axes._axes import Axes
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\axes\_axes.py", line 14, in <module>
import matplotlib.contour as mcontour
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\contour.py", line 17, in <module>
import matplotlib.text as text
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\text.py", line 16, in <module>
from .textpath import TextPath # Unused, but imported by others.
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\textpath.py", line 11, in <module>
from matplotlib.mathtext import MathTextParser
File "C:\Users\HP\AppData\Roaming\Python\Python38\site-packages\matplotlib\mathtext.py", line 27, in <module>
from PIL import Image
File "C:\Users\HP\anaconda3\lib\site-packages\PIL\Image.py", line 94, in <module>
from . import _imaging as core
**ImportError: DLL load failed while importing _imaging: Belirtilen modül bulunamadı.**
How can I fix this?
Simply upgrading the package "Pillow" (using the Anaconda environment) worked for me to resolve this issue.
pip install --upgrade Pillow
I'm trying to use Mayavi in Python 2.7, but cannot import it. My OS is Ubuntu (LTS). Here is the code:
import numpy
from mayavi.mlab import *
The following error is produced:
Traceback (most recent call last):
File "/path/to/my/script/my_script_name.py", line 2, in <module>
from mayavi import mlab
File "/usr/local/lib/python2.7/dist-packages/mayavi/mlab.py", line 16, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/usr/local/lib/python2.7/dist-packages/mayavi/tools/camera.py", line 24, in <module>
from .engine_manager import get_engine
File "/usr/local/lib/python2.7/dist-packages/mayavi/tools/engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "/usr/local/lib/python2.7/dist-packages/mayavi/preferences/api.py", line 4, in <module>
from .preference_manager import preference_manager
File "/usr/local/lib/python2.7/dist-packages/mayavi/preferences/preference_manager.py", line 30, in <module>
from apptools.preferences.api import (ScopedPreferences, IPreferences,
File "/usr/lib/python2.7/dist-packages/apptools/preferences/api.py", line 4, in <module>
from preferences import Preferences
File "/usr/lib/python2.7/dist-packages/apptools/preferences/preferences.py", line 9, in <module>
from traits.api import Property, Str, Undefined, implements
ImportError: cannot import name implements
I have tried force-reinstalling the packages mayavi, implements, traits, but to no avail. I tried both with pip and with apt.
Edit: I think the error is that mayavi cannot access VTK for my Python 2.7 installation. When I try to pip force-reinstall mayavi, I get the error "Could not find any downloads that satisfy the requirement vtk (from mayavi)". That error is described here. I do not know what to do, since both vtk and vtkpython are properly installed (with apt) and working - the issue is with mayavi and pip not knowing what to do?
These versions of softwares are installed :
python-2.5
numpy-1.0.1.win32-py2.5
scipy-0.5.2.win32-py2.5
matplotlib-0.87.7.win32-py2.5
[installed in same order]
While running my program, I am getting this error message :
*The import of the numpy version of the _transforms module,
_ns_transforms, failed. This is is either because numpy was
unavailable when matplotlib was compiled, because a dependency of
_ns_transforms could not be satisfied, or because the build flag for
this module was turned off in setup.py. If it appears that
_ns_transforms was not built, make sure you have a working copy of
numpy and then re-install matplotlib. Otherwise, the following
traceback gives more details:
Traceback (most recent call last):
File "C:\Python25\Scripts\_pictsim.py", line 16, in <module>
from pylab import plot, legend, savefig, gca, vlines, figure, title, xlabel, ylabel, semilogy,\
File "C:\Python25\Lib\site-packages\pylab.py", line 1, in <module>
>from matplotlib.pylab import *
File "C:\Python25\Lib\site-packages\matplotlib\pylab.py", line 201, in <module>
>from axes import Axes, PolarAxes
File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 14, in <module>
>from artist import Artist, setp
File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 4, in <module>
>from transforms import identity_transform
File "C:\Python25\Lib\site-packages\matplotlib\transforms.py", line 223, in <module>
>from _transforms import Value, Point, Interval, Bbox, Affine
File "C:\Python25\Lib\site-packages\matplotlib\_transforms.py", line 17, in <module>
>from matplotlib._ns_transforms import *
ImportError: DLL load failed: The specified module could not be found.*
There are some dependency errors, how can I resolve them
While installing numpy, scipy, and matplotlib it says : could not create key and set key value
The issue was resolved by downloading 2 dll files and copying in system32 and syswow64
Got this answer from another similar stackoverflow question
ImportError: DLL load failed: The specified module could not be found
The problem is likely a configuration issue, because getting the installation correct on Macs seems to be tricky. I'm running Mavericks and matplotlib 1.4.x, yet when I open a Python 2.7.5 shell and import pylib, I get this error:
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/pylab.py", line 230, in <module>
import matplotlib.finance
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/finance.py", line 38, in <module>
from matplotlib.collections import LineCollection, PolyCollection
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 55, in <module>
import matplotlib.textpath as textpath
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/mathtext.py", line 64, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so
Reason: image not found
I have libpng16 installed, but not libpng15.
I saw a hardcoded reference to libpng15 in _png.so.
Uninstall and install of matplotlib fixed the issue for me.
You can always moke it by generating a soft link like this
sudo ln -s /opt/X11/lib/libpng.dylib /usr/local/lib/libpng15.15.dylib
Not the cleaner solution but I haven't figure out why matplotlib stubbornly asks specifically for libpng15 and not any 15 or greater.
I'm using mac mountain lion(10.8.1) and python(2.7.3). And I want to use python matplotlib, numpy modules for figuring a graph.
But there's not matplotlib, numpy ver for mountain lion.
I've tested with matplotlib(1.1.1), numpy(1.7.0b1). They had been installed.
But it doesn't work like below. I just need a graph. Can mountain lion user draw a graph by python?
>>>import numpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from bumpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found. Did find:
/Libraray/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper
There isn't a specific "for Mountain Lion" numpy or matplotlib. The only compatibility consideration would be the python version, which in your case is fine. My guess is that you just need to force it to build in 64bit only:
ARCHFLAGS="-arch x86_64" pip install numpy