3

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

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

根据预配置文件,

# 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 来修复早期的错误,所以不是这样。

4

3 回答 3

1

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

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

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

于 2011-11-18T06:17:38.023 回答
1

我找到了解决办法。通过遵循我之前遵循的这些说明,我让它工作了。不同的是,上次我下载的是 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
更改检查最新版本来完成到 cantera 目录(svn checkout 或 untarred/gunzipped cantera-1.8.0)
编辑名为 preconfig 的文件并确保通过注释/编辑
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 *
于 2011-11-18T18:44:19.360 回答
1

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

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

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

自从我们开始包含它以来,没有任何问题。

于 2011-12-06T04:45:02.863 回答