Linux: installing cantera pkg for anaconda

635 views
Skip to first unread message

Madhavan Gopal

unread,
Dec 24, 2015, 4:10:54 PM12/24/15
to Cantera Users' Group
Hi all,

I have been labouring over the last 2 days trying to install cantera under linux anaconda python distribution.

for some reason it does not get installed, eventhough when I do "scons test", it shows no errors. when I enter "conda list" in the command line it does not show up

can someone please help!!

regards,

Madhavan Gopal

Bryan W. Weber

unread,
Dec 24, 2015, 4:16:47 PM12/24/15
to Cantera Users' Group
Dear Madhavan,

Today is (perhaps) your lucky day. I have just (approximately 5 minutes ago) uploaded conda packages for Cantera to anaconda.org. Although they are very much in the testing phase, I would greatly appreciate your feedback on how they work. Please type

conda install -c bryanwweber cantera

to install Cantera 2.2.0 or type

conda install -c bryanwweber/channel/devel cantera

to install the Developers release.

To actually answer your question, you need to install Cantera once you've built and tested it.

scons install

should work, but you may need to use sudo to ensure the proper write permissions, depending on where the package will be installed.

Best regards,
Bryan

Madhavan Gopal

unread,
Jan 7, 2016, 7:50:05 AM1/7/16
to Cantera Users' Group
It works great!!! Thanks for the help

Ernest Yeung

unread,
Jun 29, 2016, 10:57:30 AM6/29/16
to Cantera Users' Group
I'm on Fedora 23 Workstation (Linux) and I also was able to `conda install` the developer version as stated by Dr. Weber:


conda install -c bryanwweber/channel/devel cantera

from a user (non-admin) account.  I would highly suggest this approach to get Cantera working quickly. 

In fact (I'm going to toot my own horn here), now I can make great-looking jupyter notebooks with Cantera; I've rewritten the MatLab tutorial tut*.m files in Python, and placed them in subdirectory `cantera_stuff` of my github repository called 'Propulsion': 
https://github.com/ernestyalumni/Propulsion/tree/master/cantera_stuff
https://github.com/ernestyalumni/Propulsion

So I redid tut1.m as a jupyter notebook, and with the conda install, it works great. 
https://github.com/ernestyalumni/Propulsion/blob/master/cantera_stuff/tut1.ipynb

It might take me some time to rewrite the tutorial files that I wrote in Python into jupyter notebooks, but it's all possible.

Some lingering issues:
1. Dr. Weber (and others), where in anaconda's directory is this conda install of cantera?  I found it useful to load my own .cti and when I was using Cantera on a Mac OSX before, I was able to load the custom .cti file by placing it in the "root" directory of the Cantera local install on the Mac OSX; where would I place these files in this case?  Digging around, I see that the directory containing .cti files appear to be here:

/home/myusername/pathtowhereIputanaconda2/anaconda2/pkgs/cantera-2.3.0a2-py27_0/lib/python2.7/site-packages/cantera/data

e.g.
/home/topolo/Public/anaconda2/pkgs/cantera-2.3.0a2-py27_0/lib/python2.7/site-packages/cantera/data

Would I put it there and then be able to access it in Python?

2. With this Anaconda install, could I still use the C/C++ interface or is it not even there, i.e. is this Anaconda install purely just the Python parts (i.e. where's the .cpp files?)

3. I didn't have to do, for this conda install

scon build
scon install

at all (which was nice and easy).  Any particular reason why?

3. I'll expound on my (failed) experience building/installing Cantera on Fedora 23 Workstation (Linux) (this can be lengthy).  It would be nice to have a "native" build on Fedora/Redhat Linux. 

Fedora 23 Workstation comes with Python 2.7 and Python 3.4 by default and I installed gcc 5.*.  I had also installed Anaconda, along with its own python, etc.  pip installing numpy, etc. for Python 2.7 is easy with pip install.  However, pip3 installing numpy, etc. for Python 3.4 was difficult.  Lack of lapack, etc. libraries that numpy is dependent upon, on Python3 makes installing numpy on Python3 with pip3 difficult (and seemingly redundant). 

So I tried to get around (since I'm guessing that SConstruct goes through all of the system default Python's (NOT Anaconda's Python) this, since there was `Import Error, no numpy` everytime SConstruct got to Python 3.4 by commenting out or adding the following lines in SConstruct (in cantera/)

Added in (around) line 1086
env['python3_package'] = 'n'

Commented out (around) line 1363-1364
#if env['python3_package'] == 'y' or env['python_package'] == 'full':
#    SConscript('interfaces/cython/SConscript')

This gets around having to build for Python 3, since I didn't have numpy for python3 and didn't want to pip3 install all its dependencies.

`scons build` successfully builds, no errors, only a few warnings about, in the .cpp files that template < ... > ... are deprecated (C++11/C++14?). 

`scons test` doesn't work because of KeyError: python_module

`sudo scons install` (I switched to an admin account by now; this is tangential, but could we try to have a build of cantera on a user account?  It's always nerve-racking to make root changes on an admin account) doesn't work (despite the successful scons build).  Same error: KeyError: no `python_module` key.  Tracing the error, it seems to be with this SConscript file here

cantera/platform/posix

line 18 of SConscript, in copy_var function, with `python_module_loc'.

Ernest Yeung

unread,
Jun 29, 2016, 11:35:46 AM6/29/16
to Cantera Users' Group
Here is the error(s) that I obtain when doing sudo scons install on Fedora 23 Workstation after a successful scons build of Cantera:

```
Install file: "platform/posix/man/mixmaster.1" as "/usr/local/share/man/man1/mixmaster.1"
copy_var(["build/platform/setup_cantera"], ["platform/posix/setup_cantera.in"])
scons: *** [build/platform/setup_cantera] KeyError : 'python_module_loc'
Traceback (most recent call last):
  File "/usr/lib/scons/SCons/Action.py", line 1063, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/home/propdev/Public/cantera/platform/posix/SConscript", line 22, in copy_var
    env['python_module_loc_sc'] = env['python_module_loc']
  File "/usr/lib/scons/SCons/Environment.py", line 2324, in __getitem__
    return self.__dict__['__subject'].__getitem__(key)
  File "/usr/lib/scons/SCons/Environment.py", line 413, in __getitem__
    return self._dict[key]
KeyError: 'python_module_loc'
scons: building terminated because of errors.
```
I also noticed, after reading https://github.com/Cantera/cantera/issues/318 that my `cantera.conf` file in `cantera/` is entirely empty, compared to in the link.

Would it be possible to copy and paste and modify some of those options as in that link, to suit my situation? (e.g. no Python3 or "blank out" Python 3, no gfortran, etc.) I haven't tried it.

Again, the conda install of Cantera works great on Anaconda (thanks Dr. Weber!) and would suit most pedagogical uses for Cantera or to simply get it running quickly, but getting a build from source for Fedora/Redhat Linux would be nice.

Ray Speth

unread,
Jun 29, 2016, 12:35:47 PM6/29/16
to Cantera Users' Group
Ernest,

The Jupyter notebooks look quite nice. I had been thinking that that would be a good way of writing some Python examples since Github added rendering support for these, but hadn't had a chance to try it out. If you wanted to contribute more of these examples, that would certainly be welcome. Perhaps it would be worth having a collection of these in a repository within the Cantera organization on Github. A couple of comments on the details:
- you should probably not link to the migration guide for documentation, as that just adds a layer of confusion for anyone who isn't coming from the old Python module
- You are correct that there is no need for manual "cleanup" of Cantera objects in Python. All of this is handled automatically using Python's garbage collection.

Regarding the data directories: You should generally not be adding files to Cantera's built-in input file directory. Cantera always checks the current working directory for input files, and I think most people tend to keep the mechanism files with the scripts that use them. You can also add a directory to the search path using the function ct.add_directory (which applies only to the current Python session).

Regarding the Fedora install: It's not clear to me whether you want to build/install using the system installations of Python 2 or 3, or the Anaconda ones. If you don't want to install the Python 3 module, the correct way to disable it is by running scons with the option 'python3_package=n'.

Partial description of error messages does not help diagnose the cause. Only if you provide the input commands and their full output is there any chance of addressing these (e.g. the error running the tests). Also please provide this information when running without any modifications to SConstruct / SConscript files, to make sure that your modifications aren't part of the problem.

Of course you can install cantera as a non-root user. You only need to install as root if you are installing to a system directory such as /usr/local.

Your 'cantera.conf' file will be empty if you ran 'scons build' with no additional arguments. All that goes into this file is those arguments, so that you can rebuild without specifying all of the same options again.

Regards,
Ray

Bryan W. Weber

unread,
Jun 29, 2016, 12:46:52 PM6/29/16
to Cantera Users' Group
Dear Ernest,

I will try to reply to as many of your issues as I can. I'm glad that the conda install worked for you, I had some trouble with an install of RHEL 6 that isn't really relevant to the rest of this discussion.

Anyhow, to answer your questions,

1) As Ray mentioned, I would recommend always keeping the CTI file in your local working directory or using the add_directory function. The reason is that the files in the built-in directory can be overwritten at any time by an update of Cantera, and then you have to add back any files that you added.

2) The C++ interface is not available in the Anaconda packages, only the Python interface.

3) The Anaconda package includes the binary library that is built by the command scons build, and installs it for you to the proper place, hence no need for scons install. It is the same as installing an RPM vs building/installing from the source code.

4) It is unclear to me what your objectives are, and as Ray said, which versions of Python you want to use. Rather than commenting out lines in the SCons file (that then lead to most of the other errors you see), you can disable the Python 3 interface by writing 

scons build python3_package='n'

Please see here: http://cantera.github.io/dev-docs/sphinx/html/configuring.html#scons-config for all the configuration options you can either add to cantera.conf or put on the scons build line.

Regards,
Bryan

amadeusSharp

unread,
Jun 29, 2016, 3:22:38 PM6/29/16
to Cantera Users' Group
I have been using Cantera with Jupyter all this while, but did not face any problem with the installation? I have built it atop the python2.7 version of python accompanying Jupyter, but it is on a mac, not RHEL. I downloaded the files from github and compiled it from source. Here is my cantera.conf file for the scons install:

prefix = '/Users/homedirectory/packages/cantera2.3.0a2'

python_package = 'full'

matlab_toolbox = 'n'

f90_interface = 'n'

VERBOSE = True


as you can see, it is a pretty vanilla installation. On a terminal, if I execute "which python", here is what I get:

/Users/homeDirectory/anaconda/bin/python


Let me know if I can help debugging the conda installation or making jupyter notebooks

Regards
Santosh

Ernest Yeung

unread,
Nov 11, 2016, 5:46:11 PM11/11/16
to Cantera Users' Group
Dr. Ray Speth, Prof. Weber, Santosh Shanbhogue,

I got the git clone of Cantera to build and install with scons on Fedora 23 Workstation Linux.  I thought not having python3 was the problem months ago but it wasn't the case - there were a number of libraries (installation prerequisites) that are named differently or need to be done that wasn't needed for with the Fedora/CentOS/RedHat dnf package manager, as opposed to Ubuntu/Debian package manager.

I wrote up an installation guide for Fedora Linux of Cantera from git clone to scons build/install, and then some simple scripts (sanity check) to compile in C++ (with g++ and necessary flags):

https://github.com/ernestyalumni/Propulsion/tree/master/cantera_stuff/cantera_install_tips

Also on there are troubleshooting tips and possible errors that I came across and troubleshooted (that others might encounter), and screenshots of what the installation should look like. 

I'll also copy what I documented on my wordpress blog.

https://ernestyalumni.wordpress.com/2016/11/11/cantera-installation-tips-on-fedora-linux-namely-fedora-23-workstation-linux/

I'll make a new post sharing how I installed on Fedora Linux, which should work on CentOS and RedHat. 

Even if python3 was a problem, scons skips over it and builds and installs as expected, if python-devel is installed, via sudo dnf install.  

Thanks, -EY

PS. I'm throwing this out there.  I've been picking up Cantera, combustion for liquid-propellant rocket engines, because I want to work at SpaceX, namely for their combustion modeling team.  I want to help them build the most high-fidelity direct numerical simulation of combustion compressible fluid flow entire computed on the GPU, using CUDA C/C++11.  I've tried to apply and included YouTube presentation of CFD code using finite difference methods (which I strongly believe I've optimized better than previous implementations on the shared memory of the GPU) and 1-dimensional liquid droplet combustion and compressible flow (with Cantera):

https://www.youtube.com/playlist?list=PLzrtxrRuWAhJQj-9do_IVM2YZw7IcEFjy

I'm fairly confident they overlook my applications (I check my Google Analytics/YouTube views).  Do you know someone that could help me make an introduction and ultimately an internal referral for SpaceX?  And if this preliminary independent work isn't enough, could you please give me some advice on some other things I could model or program up towards combustion CFD?  I'm pushing for this because I strongly believe I've implemented the most general (to any order and for 2-dim., 3-dim.) implementation, that's scalable (naturally with CUDA C/C++), on the GPU and I do believe in the mission at SpaceX. 

-Ernest Yeung.
Reply all
Reply to author
Forward
0 new messages