Question

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.

Was it helpful?

Solution 2

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 *

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top