Importing matplotlib in Spyder (OSX 10.6) - python

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.

Related

Python embedding, ImportError: cannot import name _remove_dead_weakref

I am trying to run some C++ code with embedded Python. Code was working completely fine a couple of weeks ago. The code still compiles, but I am now getting the error
Traceback (most recent call last):
File "./main.py", line 1, in <module>
import numpy as np
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 74, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/usr/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in <module>
from unittest import TestCase
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/__init__.py", line 64, in <module>
from .main import TestProgram, main
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 7, in <module>
from . import loader, runner
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py", line 7, in <module>
from .signals import registerResult
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/signals.py", line 2, in <module>
import weakref
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Since then the only change I have made is to install the macOS Supplemental Update and to upgrade Python from 2.7.13_1 to 2.7.14_2 (using Homebrew). I have changed the relevant linker flags in the makefile, i.e. those that appear when I type python-config --ldflags. I have also made sure that the Python I am using is definitely the Homebrew one by inserting export PATH="/usr/local/opt/python/libexec/bin:$PATH" into my .bash_profile as directed by Homebrew.
I am not sure whether this error is because of the Python update, the recent macOS Supplemental Update, or something else. Any idea what the problem could be?
Thanks
I had the same problem;
In python 2.7 the NumPy 1.8.0 was available,
Then I installed NumPy (again) using brew, and it wasn't available in my python (2.7) anymore. (Got the same error you got here)
So I did "brew unlink python && brew link python" to use python 3 (instead of 2) which NumPy 1.14 is available in it.
I guess the python 2.7 was not compatible with this recent version of NumPy.

Script fails in WinPython, attempting to import lapack_til

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

I uninstalled matplotlib, tried to reinstall it and it failed to be imported. [OS X]

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/

Python 2.7: Unable to import matplotlib.pyplot

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.

running a python script that requires matplotlib gives: ImportError: undefined symbol: __libm_sse2_sincos

A specific package that I'm trying to run is fastStructure. After installing all the requirements (numpy, scipy, cython, gsl, matplotlib), when I try to execute the script I get the following error:
python distruct.py
Traceback (most recent call last):
File "distruct.py", line 2, in <module>
import matplotlib.pyplot as plot
File "/data003/GIF/software/packages/python/2.7.9/lib/python2.7/site-packages/matplotlib/pyplot.py", line 24, in <module>
import matplotlib.colorbar
File "/data003/GIF/software/packages/python/2.7.9/lib/python2.7/site-packages/matplotlib/colorbar.py", line 27, in <module>
import matplotlib.artist as martist
File "/data003/GIF/software/packages/python/2.7.9/lib/python2.7/site-packages/matplotlib/artist.py", line 8, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/data003/GIF/software/packages/python/2.7.9/lib/python2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: /data003/GIF/software/packages/python/2.7.9/lib/python2.7/site-packages/matplotlib/_path.so: undefined symbol: __libm_sse2_sincos
Does this mean that some of the requirements weren't properly installed? or Am I missing some of the basic packages that are supposed to be there on all computers?
If it helps I am on a large HPC cluster, running RHEL with intel processors.
I am unable to find any information about this error and I am unable to move forward. Any help will be greatly appreciated.
EDIT:
Specifically,
import matplotlib.pyplot as plot
is what causing this error.

Categories

Resources