Problems with scipy package import when using mwpython

25 views (last 30 days)
Michael on 10 Aug 2018
Commented: Michael on 10 Aug 2018
I have created a Python package with MATLAB Compiler SDK (R2018a). I have been able to include that package and execute functions in Python, but have been having trouble with including other Python packages in my Python script. I am on a Mac and as such I have to use the Matlab script mwpython to run my Matlab generated Python packages. When I try to import I get the following:
CEFNS-Mavericks:~ mws22$ mwpython
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/", line 97, in <module>
from .matlab import loadmat, savemat, whosmat, byteordercodes
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/matlab/", line 13, in <module>
from .mio import loadmat, savemat, whosmat
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/matlab/", line 12, in <module>
from .miobase import get_matfile_version, docfiller
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/matlab/", line 22, in <module>
from scipy.misc import doccer
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/misc/", line 68, in <module>
from scipy.interpolate._pade import pade as _pade
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/interpolate/", line 175, in <module>
from .interpolate import *
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/interpolate/", line 21, in <module>
import scipy.special as spec
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/", line 640, in <module>
from ._ufuncs import *
ImportError: dlopen(/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/, 2): Symbol not found: __gfortran_stop_numeric_f08
Referenced from: /Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/
Expected in: /Applications/
in /Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/
As you can see, the import of scipy works fine, but throws an error that I can't seem to figure out. What is weird is that if I run >>python rather than >>mwpython the imports just fine. That lead me to think it was a problem with my sys path variable. In mwpython, when I do import sys and sys.path I get:
In mwpython, when I do import sys and sys.path I get:
They both point to /Users/mws22/anaconda2/lib/python2.7/site-packages where I know scipy is installed (io is a subdirectory of scipy).
I am at a loss as to what to do to be able to use scipy and my MATLAB generated python packages in the same program. Any help would be appreciated.
  1 Comment
Michael on 10 Aug 2018
A related note: I am having the same problem with matplotlib. I can import matplotlib just fine, but matplotlib.pyplot throws the following:
>>> import matplotlib.pyplot as platform
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/", line 31, in <module>
import matplotlib.colorbar
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/", line 36, in <module>
import matplotlib.contour as contour
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/", line 20, in <module>
import matplotlib.font_manager as font_manager
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/", line 55, in <module>
from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
ImportError: dlopen(/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/, 2): Library not loaded: @rpath/libfreetype.6.dylib
Referenced from: /Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/
Reason: Incompatible library version: requires version 21.0.0 or later, but libfreetype.6.dylib provides version 18.0.0

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!