JModelica:Python Shell 和 IPython 导入包时遇到问题

JModelica: Python Shell and IPython trouble importing package

所以我刚刚安装了 JModelica,并且包含了 Python 2.7。当我使用 IPython-console 并尝试导入以下内容时(有效):

从 pymodelica 导入 compile_fmu

然而,当我在 Python Shell 程序中写这个时,它说:

回溯(最后一次调用): 文件“”,第 1 行,位于 从 pymodelica 导入 compile_fmu ImportError:没有名为 pymodelica ****

的模块

这里有什么问题?我想使用 Python Shell,因为您可以在那里编写脚本。

此致, 贾西尔

问题是 Python 需要知道 JModelica 存储 Python 包 "pymodelica" 的路径。如果您使用 JModelica 安装中的 IPython,这会自动设置正确的路径。常规 Python shell 也是如此,如果您使用 JModelica 安装中的 link,它应该可以工作,而如果您使用 Python shell直接从您的 Python 安装,它不会工作。