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 scipy.io 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 scipy.io
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/__init__.py", line 97, in <module>
from .matlab import loadmat, savemat, whosmat, byteordercodes
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/matlab/__init__.py", line 13, in <module>
from .mio import loadmat, savemat, whosmat
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/matlab/mio.py", line 12, in <module>
from .miobase import get_matfile_version, docfiller
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/io/matlab/miobase.py", line 22, in <module>
from scipy.misc import doccer
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/misc/__init__.py", line 68, in <module>
from scipy.interpolate._pade import pade as _pade
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/interpolate/__init__.py", line 175, in <module>
from .interpolate import *
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 21, in <module>
import scipy.special as spec
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: dlopen(/Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/_ufuncs.so, 2): Symbol not found: __gfortran_stop_numeric_f08
Referenced from: /Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/_ufuncs.so
Expected in: /Applications/MATLAB_R2018a.app/sys/os/maci64/libgfortran.3.dylib
in /Users/mws22/anaconda2/lib/python2.7/site-packages/scipy/special/_ufuncs.so
As you can see, the import of scipy works fine, but scipy.io throws an error that I can't seem to figure out. What is weird is that if I run >>python rather than >>mwpython the scipy.io 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:
'/Users/mws22/anaconda2/lib/python2.7/site-packages'
'/Library/Python/2.7/site-packages'
'/Users/mws22/anaconda2/lib/python27.zip'
'/Users/mws22/anaconda2/lib/python2.7'
'/Users/mws22/anaconda2/lib/python2.7/plat-darwin'
'/Users/mws22/anaconda2/lib/python2.7/plat-mac'
'/Users/mws22/anaconda2/lib/python2.7/plat-mac/lib-scriptpackages'
'/Users/mws22/anaconda2/lib/python2.7/lib-tk'
'/Users/mws22/anaconda2/lib/python2.7/lib-old'
'/Users/mws22/anaconda2/lib/python2.7/lib-dynload'
'/Users/mws22/anaconda2/lib/python2.7/site-packages/aeosa'
In mwpython, when I do import sys and sys.path I get:
'/Users/mws22/anaconda2/lib/python2.7/site-packages'
'/Library/Python/2.7/site-packages'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload'
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages'
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.