【问题标题】:trouble compiling and installing cantera python module编译和安装cantera python模块的麻烦
【发布时间】:2011-11-17 22:37:05
【问题描述】:

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

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

【问题讨论】:

  • 为 Ubuntu 安装相关软件包可能比尝试使用 EPD 更容易。或者您可以尝试询问 EPD 用户列表以检查您是否找到了正确的路径。
  • 如果我同时安装了 EPD 和 Ubuntu 发行版 numpy,ipython 将使用 EPD 版本还是 python 发行版?我认为我可以在 ~/.bashrc 中指定它是否正确?
  • 原来我已经有了相关的 Ubuntu 包,所以它一定是别的东西。

标签: python linux ubuntu failed-installation cantera


【解决方案1】:

您的 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 时使用 未安装在默认目录中)应保持不变。希望 这有帮助。

【讨论】:

    【解决方案2】:

    我找到了解决办法。通过关注我之前关注的these instructions,我得到了它的工作。不同的是,上次我下载的是 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 *
    

    【讨论】:

      【解决方案3】:

      我们从来没有通过在 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
      

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

      【讨论】:

      • 出于某种原因,我之前没有这样做就让它工作了。在我当前的 Ubuntu 安装中,安装程序在没有调整的情况下无法工作。然后我尝试了 if..then 语句,它仍然不起作用。然后,我明确说明了路径,而不是使用 python 命令,现在我已经设置好了。非常感谢!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-25
      相关资源
      最近更新 更多