编译和安装 cantera python 模块时遇到问题

发布于 2024-12-16 19:14:40 字数 958 浏览 3 评论 0原文

我正在尝试在 Ubuntu linux 中将 Cantera 作为 python 模块安装。作为参考,我使用了以下说明: 安装 Cantera。运行 ./preconfigmake 后,出现以下错误:

fatal error: numarray/arrayobject.h: No such file or directory

根据 preconfig 文件,

# If numpy was installed using the --home option, set this to the
# home directory for numpy. This will be needed for all numpy installations
# that don't put the include files into python's native include directory.
#NUMPY_HOME=${NUMPY_HOME:="$HOME/python_packages"}

我使用的是学生版 Enthought Python Distribution 所以我想也许我需要将最后一行更改为:

NUMPY_HOME=${NUMPY_HOME:="/usr/local/EPD/lib/python2.7/site-packages/"}

但这不起作用。我仍然遇到同样的错误。想法?我已经安装了 python-dev 来修复早期的错误,所以不是这样。

I'm attempting to install the Cantera as a python module within Ubuntu linux. For reference I used these instructions: Installing Cantera. After running ./preconfig and make, I get the following error:

fatal error: numarray/arrayobject.h: No such file or directory

According to the preconfig file,

# If numpy was installed using the --home option, set this to the
# home directory for numpy. This will be needed for all numpy installations
# that don't put the include files into python's native include directory.
#NUMPY_HOME=${NUMPY_HOME:="$HOME/python_packages"}

and I'm using the student version of Enthought Python Distribution so I thought maybe I need to change the last line to:

NUMPY_HOME=${NUMPY_HOME:="/usr/local/EPD/lib/python2.7/site-packages/"}

but this is not working. I still get the same error. Thoughts? I've installed python-dev to fix an earlier bug so that's not it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故事和酒 2024-12-23 19:14:40

您的 Ubuntu 机器上可能有多个 Python 发行版。在
为了使用 EPD 安装 Cantera 您应该明确告诉它
使用哪个发行版:

PYTHON_CMD=${PYTHON_CMD:="/usr/local/EPD/bin/python"}

每个发行版都有自己的 site-packages 目录,因此
指定 PYTHON_CMD 您还可以指定要使用的site-packages
安装 Numpy 时,它还会安装 Numarray 的接口
site-packages/numpy/core/include/numpy,所以不需要
下载Numarray。此外,numpy 已安装到 site-packages
EPD 目录,因此 NUMPY_HOME (仅当 numpy
未安装在默认目录中)应保持原样。希望
这有帮助。

You probably have several Python distributions on your Ubuntu box. In
order to use EPD to install Cantera you should tell it explicitly
which distribution to use:

PYTHON_CMD=${PYTHON_CMD:="/usr/local/EPD/bin/python"}

Every distribution has its own site-packages directory, so by
specifying PYTHON_CMD you also specify which site-packages to use.
When Numpy is installed, it also installs interfaces to Numarray to
site-packages/numpy/core/include/numpy, so there is no need to
download Numarray. Also, numpy is installed to site-packages
directory of EPD, so NUMPY_HOME (which is used only when numpy
is not installed in the default directory) should be left intact. Hope
this helps.

做个少女永远怀春 2024-12-23 19:14:40

我找到了解决方法。按照 我之前遵循了这些说明,我让它工作了。不同的是,上次我下载了 tar.gz 文件,而这次我使用了 subversion 存储库,我猜它可能更新得更多。无论如何,它有效,而且我也不需要更改默认的 python 命令。

编辑:我确实需要将其从默认值更改为:

PYTHON_CMD=${PYTHON_CMD:="/usr/local/EPD/bin/python"}

我想最好也发布说明,以便其他用户可以在此处使用它们:

第一步是安装所有依赖项。这是由 apt-get 处理的:
sudo apt-get install subversion g++ gfortran python2.6-dev python-numpy libsundials* graphviz

下一步是获取 cantera 的源代码。这可以通过从 cantera 网站下载 cantera-1.8.0-beta-tar.gz 并从 svn 检查最新版本来完成
svn checkout http://cantera.googlecode.com/svn/cantera18/trunk/坎特拉

更改为 cantera 目录(svn checkout 或解压/gunzipped cantera-1.8.0)

编辑名为 preconfig 的文件,并通过注释/编辑确保包含以下行

PYTHON_PACKAGE=${PYTHON_PACKAGE:="完整"}

USE_NUMPY=${USE_NUMPY:="y"}

SUNDIALS_VERSION=${SUNDIALS_VERSION:='2.3'}

Then in a terminal run the following commands:
./preconfig
make
sudo make install
source ~/setup_cantera
If every thing went well you should be able to import the Cantera module in python:
python
>>>from Cantera import *

I found a fix. By following these instructions that I had previously followed, I got it to work. The difference is that the last time, I downloaded the tar.gz file, and this time, I used the subversion repository, which might be more updated I guess. Anyway, it worked, and I did not need to change the default python command either.

Edit: I did need to change this from the default to:

PYTHON_CMD=${PYTHON_CMD:="/usr/local/EPD/bin/python"}

I guess it's a good idea to also post the instructions so they're available here for other users:

First step is to install any dependencies. This is handled by apt-get:
sudo apt-get install subversion g++ gfortran python2.6-dev python-numpy libsundials* graphviz

Next step is to get the source for cantera. This can be done by either downloading the cantera-1.8.0-beta-tar.gz from the cantera site our checking the latest version from svn
svn checkout http://cantera.googlecode.com/svn/cantera18/trunk/ cantera

Change to the cantera directory (either the svn checkout or the untarred/gunzipped cantera-1.8.0)

Edit the file named preconfig and make sure the following lines are included by commenting/editing

PYTHON_PACKAGE=${PYTHON_PACKAGE:="full"}

USE_NUMPY=${USE_NUMPY:="y"}

SUNDIALS_VERSION=${SUNDIALS_VERSION:='2.3'}

Then in a terminal run the following commands:
./preconfig
make
sudo make install
source ~/setup_cantera
If every thing went well you should be able to import the Cantera module in python:
python
>>>from Cantera import *
旧情别恋 2024-12-23 19:14:40

我们从来没有通过在 pre_config 中设置 include 变量来让它工作。相反,我们这样做:

...
USE_NUMPY=${USE_NUMPY:="y"}

if [ "$USE_NUMPY" = "y" ]; then
    export NUMPY_INC_DIR=`python -c 'import numpy; print numpy.get_include()'`
fi

自从我们开始包含这一点以来,没有遇到任何问题。

We've never gotten it to work by just setting the include variable in pre_config. Instead, we do:

...
USE_NUMPY=${USE_NUMPY:="y"}

if [ "$USE_NUMPY" = "y" ]; then
    export NUMPY_INC_DIR=`python -c 'import numpy; print numpy.get_include()'`
fi

Haven't had any issues since we've started including that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文