Problems with scipy package import when using mwpython

4 Ansichten (letzte 30 Tage)
Michael
Michael am 10 Aug. 2018
Kommentiert: Michael am 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 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.
  1 Kommentar
Michael
Michael am 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/pyplot.py", line 31, in <module>
import matplotlib.colorbar
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/colorbar.py", line 36, in <module>
import matplotlib.contour as contour
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/contour.py", line 20, in <module>
import matplotlib.font_manager as font_manager
File "/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py", line 55, in <module>
from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
ImportError: dlopen(/Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/ft2font.so, 2): Library not loaded: @rpath/libfreetype.6.dylib
Referenced from: /Users/mws22/anaconda2/lib/python2.7/site-packages/matplotlib/ft2font.so
Reason: Incompatible library version: ft2font.so requires version 21.0.0 or later, but libfreetype.6.dylib provides version 18.0.0

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Python Package Integration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by