0

我在 Mac OS X 上运行 Python,并尝试使用 Orange 包。

我已经安装了捆绑包,但无法导入 Orange 包。我尝试删除并重新安装所有内容,但仍然收到错误消息:

Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 20:34:45) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type  "copyright", "credits" or "license()" for more information.
>>> import sys
>>> import Orange

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import Orange
ImportError: No module named Orange
>>> import Orange

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import Orange
ImportError: No module named Orange
>>> import orange

Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import orange
ImportError: No module named orange

有一个类似的线程(Importing Orange 返回 "ImportError: no module named orange"),但唯一的建议是使用小写的橙色。不幸的是,这并不能解决问题。有什么建议吗?

谢谢!

4

1 回答 1

0

OSX 上的 Orange .dmg 安装程序不会将库安装在系统的(自制软件或任何其他)python 站点包目录中。它是一个自包含的 .app,带有自己的 python 解释器。

/Applications/Orange.app/Contents/MacOS/python您可以通过运行(或者/Applications/Orange.app/Contents/MacOS/ipython如果您愿意)来启动 Orange 的 python 解释器。

或者,您可以将 Orange 的站点包目录添加到 python 的搜索路径

export PYTHONPATH="/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/"
python -c "import Orange"

请注意,这会将 Orange 附带的所有包(numpy、scipy、...)添加到搜索路径中,并且可能会覆盖系统 python 中已安装的包。谨慎使用。

于 2014-12-16T09:04:02.927 回答