简体   繁体   中英

Python - cannot import slycot module in spyder (RuntimeError & ImportError)

When I try to import the slycot module in spyder (version 2.2), I get the following error:

RuntimeError: module compiled against API version 7 but this version of numpy is 6
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/__init__.py",  
line 4, in <module>
    from slycot.analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, ab09ad
  File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/analysis.py",
line 21, in <module>
    from slycot import _wrapper
ImportError: numpy.core.multiarray failed to import

Now, when I import slycot in the python shell through my terminal, there are no problems at all. I think the reason why there are no problems through the terminal, is that I recently installed numpy 1.7.1. Spyder on the other hand still uses numpy 1.6.2.,hence the error.

I tried to change the numpy version in spyder, but so far that didn't work. When I change the numpy(6) folder in my spyder lib with the recently installed numpy(7), I get the following error (in spyder):

ImportError: Error importing numpy: you should not try to import numpy from
    its source directory; please exit the numpy source tree, and relaunch
    your python intepreter from there.

What is the best way to solve this error?

Thanks in advance.

(Spyder dev here) At the moment it's not possible for the user to install anything inside the app. I guess you moved your slycot module from another interpreter to our App (because of the numpy error you mention).

The right way to use different modules not present in the app, is to change the path of your interpreter in:

Tools > Preferences > Console > Advanced settings > Python executable

If you installed slycot using your system Python, you have to select

/usr/bin/python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM