【问题标题】:Python - cannot import slycot module in spyder (RuntimeError & ImportError)Python - 无法在 spyder 中导入 slycot 模块(RuntimeError 和 ImportError)
【发布时间】:2013-05-20 09:51:02
【问题描述】:

当我尝试在 spyder(2.2 版)中导入 slycot 模块时,出现以下错误:

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

现在,当我通过终端在 python shell 中导入 slycot 时,完全没有问题。我认为通过终端没有问题的原因是我最近安装了numpy 1.7.1。另一方面,Spyder 仍然使用 numpy 1.6.2.,因此出现错误。

我尝试在 spyder 中更改 numpy 版本,但到目前为止还没有成功。 当我使用最近安装的 numpy(7) 更改 spyder lib 中的 numpy(6) 文件夹时,我收到以下错误(在 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.

解决此错误的最佳方法是什么?

提前致谢。

【问题讨论】:

    标签: python importerror spyder


    【解决方案1】:

    (此处为 Spyder 开发人员)目前用户无法在应用程序中安装任何内容。我猜你将你的 slycot 模块从另一个解释器移到了我们的应用程序(因为你提到的 numpy 错误)。

    使用应用程序中不存在的不同模块的正确方法是更改​​解释器的路径:

    工具 > 首选项 > 控制台 > 高级设置 > Python 可执行文件

    如果您使用系统 Python 安装了 slycot,则必须选择

    /usr/bin/python

    【讨论】:

    • 我在Spyder中使用了不同的模块,如sympy,Tkinker等,安装后通过复制Spyder lib中的模块文件夹。到目前为止,这工作得很好。当我更改解释器的路径时,我收到以下消息:“python:posix_spawn:/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:没有这样的文件或目录”我可能做错了什么,我是否也必须更改 PYTHONSTARTUP?
    • 在终端中运行which python 会得到什么?这是您需要放入 Python 可执行文件 的路径,而不是您选择的路径。此外,该应用程序附带 Sympy 和 Tkinter。 slycot 的问题在于它是用不同的 numpy 版本编译的,正如你猜对的那样。
    • 我得到 '/Library/Frameworks/Python.framework/Versions/2.7/bin/python',它已经尝试放入 Python 可执行文件,但随后出现错误:'ImportError: cannot导入名称 urandom'。我试图找到一个解决方案来解决这个问题,但到目前为止没有成功..
    • 你使用的是什么 Spyder 版本?
    • Spyder 2.2.0dev, ("Python 2.7.3, Qt 4.8.2, PyQt4 (API v2) 4.9.4 on Darwin")
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    • 1970-01-01
    • 2020-06-16
    • 1970-01-01
    • 1970-01-01
    • 2013-12-27
    • 2013-05-17
    相关资源
    最近更新 更多