When I tried to
import matplotlib.pyplot as plt
I was given the following error:
runfile('/Users/Zhengnan/Documents/Python/PS 2/230I_PS_2.py', wdir='/Users/Zhengnan/Documents/Python/PS 2')
Traceback (most recent call last):
File "<ipython-input-2-9001323bba15>", line 1, in <module>
runfile('/Users/Zhengnan/Documents/Python/PS 2/230I_PS_2.py', wdir='/Users/Zhengnan/Documents/Python/PS 2')
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 78, in execfile
builtins.execfile(filename, *where)
File "/Users/Zhengnan/Documents/Python/PS 2/230I_PS_2.py", line 4, in <module>
import matplotlib.pyplot as plt
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/mathtext.py", line 63, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: #loader_path/../../../libpng15.15.dylib
Referenced from: /Users/Zhengnan/anaconda/lib/python2.7/site-packages/matplotlib/_png.so
Reason: image not found
Can anyone please help me? I'm a newbie and not really familiar with paths. A step-by-step instruction would be greatly appreciated. Thanks in advance.
BTW, I'm using spyder as an IDE.
as presented here:
https://askubuntu.com/questions/636937/python-2-7-matplotlib-provides-errorpyplot
this command will fix it:
conda install matplotlib
and indeed it helped me.
I use Kali Linux,I use:
pip install matplotlib
It's likely your library path is not set up correctly, and doesn't point to wherever the file libpng15.15.dylib is located.
Since this file should probably come with the anaconda installation (provided this is how you have installed Python and matplotlib), check if you can find this file in /Users/Zhangnan/anaconda/lib/.
If you find that file there, set your LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/Users/Zhangnan/anaconda/lib/
You may also want to add that line to your ${HOME}/.bashrc file.
Related
I'm trying to run a script my client has provided, but I can't get it to start; it seems certainly a setup question on my machine, as it works for them. I started by installing WinPython from http://scipy.org/, but I'm now getting the following traceback:
Traceback (most recent call last):
File "pyconsole.py", line 18, in <module>
import cocomo
File "pyconsole\cocomo.py", line 13, in <module>
import grupple
File "pyconsole\grupple.py", line 4, in <module>
import matplotlib.mlab as mlab
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\matplotlib\__init__.py", line 134, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\matplotlib\rcsetup.py", line 19, in <module>
from matplotlib.colors import is_color_like
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\matplotlib\colors.py", line 52, in <module>
import numpy as np
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\numpy\__init__.py", line 137, in <module>
import add_newdocs
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\numpy\lib\__init__.py", line 13, in <module>
from polynomial import *
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\numpy\lib\polynomial.py", line 17, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\numpy\linalg\__init__.py", line 48, in <module>
from linalg import *
File "C:\Users\lab\AppData\Roaming\Python\Python27\site-packages\numpy\linalg\linalg.py", line 23, in <module>
from numpy.linalg import lapack_lite
ImportError: DLL load failed: The specified module could not be found.
I'm not confident in interpreting Python tracebacks, but it seems that "lapack_lite" is missing? Searching around a bit seems surprisingly unhelpful; the best I've seemed to determine is that it is part of numpy? But that's odd, as the reason I started with the WinPython distribution is that the numpy stack is pre-installed, and that is the easiest way to get started with that.
What am I missing?
Thanks!
i think the easiest way under Windows would be to simply install Anaconda (this takes care of all the dependencies of Numpy and Scipy). You can download it from here:
https://www.continuum.io/downloads
This way you dont have to scroll through pages of Documentation on how to get all dependencies right.
Kind regards
Johann
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 am using Spyder with python 2.7 and matplotlib on a windows machine.
I am trying to run my script and I am getting the following error:
runfile('C:/Python27/Scripts/python-serial-plot.py', wdir=r'C:/Python27/Scripts')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 601, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 66, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Python27/Scripts/python-serial-plot.py", line 8, in <module>
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_gtkagg.py", line 14, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_gtk.py", line 36, in <module>
from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_gdk.py", line 33, in <module>
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
ImportError: No module named _backend_gdk
I went to the directory where the backends are stored and can't see _backend_gdk.
How can I fix this issue?
You need to change your graphics backend to fix this error. In Spyder you need to go to
Tools > Preferences > IPython console > Graphics > Graphics backend
and select there either Inline or Automatic there.
You can switch the backend to list all backends:
In [5]: import matplotlib
In [6]: matplotlib.rcsetup.all_backends
Then use matplotlib.use('some_backend') to choose another, I don't use windows so cannot recommend what to use but you can try different ones and see what works best.
The matplotlib.use('some_backend') should be before any import matplotlib.pyplot etc.. statements
what is a backend
When importing matplotlib in Spyder I get the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/textpath.py", line 19, in <module>
import matplotlib.font_manager as font_manager
File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/font_manager.py", line 57, in <module>
from matplotlib import ft2font
ImportError: dlopen(/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/matplotlib/ft2font.so, 2): Symbol not found: _inflateReset2
Referenced from: /Applications/Spyder-Py2.app/Contents/MacOS/../Frameworks/libpng16.16.dylib
Expected in: /usr/lib/libz.1.dylib
in /Applications/Spyder-Py2.app/Contents/MacOS/../Frameworks/libpng16.16.dylib
What can I do? I really don't get it. I run under mac OSX 10.6
(Spyder dev here) The problem lies in some changes done by the Matplotlib team some time ago that made for us harder to support Mac OSX 10.6.
To do it, we would need to include our own version of zlib in our Mac app, and compile every package against it, something I considered too much work and a potential cause of bugs.
That's why I changed the minimal required version of our app to be 10.7, as can be seen in our documentation site.
When I try to use this command line to run this python code:
~/Tools/find_differential_primers/utils python stitch_six_frame_stops.py seq.fa
Error code will be displayed as followed. could you help me solve this problem.
Traceback (most recent call last):
File "stitch_six_frame_stops.py", line 55, in <module>
import matplotlib
File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.x-py2.7-macosx-10.8 intel.egg/matplotlib/__init__.py", line 129, in <module>
from matplotlib.cbook import is_string_like
File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/cbook.py", line 28, in <module>
import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy-1.8.0.dev_3084618_20130514-py2.7-macosx-10.8-intel.egg/numpy/__init__.py", line 140, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy-1.8.0.dev_3084618_20130514-py2.7-macosx-10.8-intel.egg/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy-1.8.0.dev_3084618_20130514-py2.7-macosx-10.8-intel.egg/numpy/lib/__init__.py", line 6, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy-1.8.0.dev_3084618_20130514-py2.7-macosx-10.8-intel.egg/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy-1.8.0.dev_3084618_20130514-py2.7-macosx-10.8-intel.egg/numpy/core/__init__.py", line 6, in <module>
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy-1.8.0.dev_3084618_20130514-py2.7-macosx-10.8-intel.egg/numpy/core/multiarray.so: invalid ELF header
You are trying to use a .so file in Mac OSX! .so files work on Linux; Mac OSX works with .dynld files. You probably may want to verify your NumPy Installation.
Assuming you are using OSX Lion, please see here for how to install NumPy on the OSX.