New Homebrew formula for Mac OS X installation

1,113 views
Skip to first unread message

Ray Speth

unread,
Jul 28, 2014, 4:16:04 PM7/28/14
to canter...@googlegroups.com
Hi all,

I have some good news for Mac users. I recently wrote a new Homebrew formula for Cantera, which has now been added to homebrew/science and should significantly simplify the process of installing Cantera on OS X. The following instructions should work for most users. If there's anything that doesn't, please let me know.

Regards,
Ray

-----

Prerequisites
(If you've used Homebrew before, you've probably already completed some of these steps and can skip them)
  • Install XCode from the App store
  • From a Terminal, run 'sudo xcodebuild' and agree to the XCode license agreement
  • Install Homebrew
  • Run: brew tap homebrew/science
  • Run: brew install python scons sundials
  • Put '/usr/local/bin' at the front of your path, e.g. add the following to ~/.bash_profile (creating this file if it doesn't already exist):
  • export PATH=/usr/local/bin:$PATH
  • Run: source ~/.bash_profile
  • If you want to build the Cantera Python 2 module:
    • Run: pip install cython numpy
  • If you want to build the Cantera Python 3 module:
    • Run: brew install python3
    • Run: pip3 install numpy cython
Installing Cantera:

The installation command for Cantera supports several options:
  • To install Cantera with additional patches that will be included in the next maintenance release: '--devel'
  • To Install the current development version of Cantera: '--HEAD'
  • To install the Matlab toolbox: '--with-matlab=/Applications/MATLAB_R2014a.app/' (with the version modified to match your installed Matlab version)
Add the desired options to the 'brew install' command, e.g.:
  • Run: brew install cantera --devel --with-matlab=/Applications/MATLAB_R2014a.app/

Andrew Butcher

unread,
Aug 7, 2014, 9:03:24 AM8/7/14
to canter...@googlegroups.com
Dear Ray,

This is a very exciting development and as a Mac user, thanks for getting this through.

Something seems to wrong however, as the brew install cantera command, as of today (2014-08-07), with an updated homebrew (a6880419), shows that the formula for Cantera is not available!

Best Regards,

Andrew

Ray Speth

unread,
Aug 12, 2014, 3:46:37 PM8/12/14
to canter...@googlegroups.com
Andrew,

The Cantera formula is in the homebrew/science tap. Have you added that tap and updated it? The formula definitely exists:


Regards,
Ray

Kyle Niemeyer

unread,
Aug 15, 2014, 2:42:17 PM8/15/14
to canter...@googlegroups.com
Andrew & Ray:

When I just tried to install cantera via homebrew (or reinstall, in my case), just doing `brew install cantera` didn't work, and `brew search cantera` didn't bring any results—and I have homebrew/science tapped.

However, doing `brew install homebrew/science/cantera ...` did work for me.

Ray Speth

unread,
Aug 29, 2014, 2:44:53 PM8/29/14
to canter...@googlegroups.com
Kyle and Andrew,

Were you able to resolve these issues with using the Homebrew formula? If you have homebrew/science tapped and then run 'brew update', it should then be possible to install Cantera with just 'brew install cantera'. If that's not sufficient, I'd like to know what's happening so I can update the instructions accordingly. Does 'brew doctor' report anything?

Regards,
Ray

Andrew Butcher

unread,
Aug 30, 2014, 12:42:55 PM8/30/14
to canter...@googlegroups.com
Hi Ray,

Yes, the problem was resolved with tapping homebrew/science and I have had several colleagues install cantera on Mac OSX Mavericks without any problems, in other words it is repeatable and painless.

Thanks again!

Best Regards,

Andrew


--
You received this message because you are subscribed to a topic in the Google Groups "Cantera Users' Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cantera-users/qh6rfUVgIzM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.
To post to this group, send email to canter...@googlegroups.com.
Visit this group at http://groups.google.com/group/cantera-users.
For more options, visit https://groups.google.com/d/optout.

Jeffrey Komives

unread,
Oct 2, 2014, 11:20:18 AM10/2/14
to canter...@googlegroups.com
Ray, thanks so much for putting this together!  I had no issues downloading and installing Cantera, but I'm having issues with the Matlab installation.  After installing with brew install cantera --with-matlab=/Applications/MATLAB_R2014a.app/  there appears to be no additions to the matlab toolboxes in the Matlab app bundle.

Steven DeCaluwe

unread,
Oct 2, 2014, 12:43:26 PM10/2/14
to canter...@googlegroups.com
Hi Jeffrey, 

The cantera/matlab toolbox does not live inside the matlab app, but instead in usr/local/lib/cantera

I am guessing that you still need to add the pathway to this toolbox to your matlab path, and set some environment variables to allow Matlab to find the python interpreter.  Because 'use' is a hidden folder, the easiest way to do this is to add the following lines a file 'startup.m' that is in your main matlab toolbox ('Documents/MATLAB' for me).  If this file does not already exist, go ahead and create it, and add:

path('/usr/local/lib/cantera/matlab/toolbox', path)

path('/usr/local/lib/cantera/matlab/toolbox/1D', path)

setenv('PYTHON_CMD', '/usr/local/bin/python3')

setenv('PYTHONPATH', [getenv('PYTHONPATH'), ':/usr/local/lib/python3.3/site-packages/cantera'])

setenv('PYTHONPATH', [getenv('PYTHONPATH'), ':/usr/local/lib/python3.3/site-packages'])


For the last three lines, these need to point to the python3 interpreter (open a terminal window and run 'which python3'), plus the python3 'site-packages' folder where ctml_writer.py is found.  

Only one of the last two lines is actually needed - just search in that general area, for the relevant python3.x installation until you find ctml_writer.py

Hope this helps!
Steven


On Thu, Oct 2, 2014 at 9:20 AM, Jeffrey Komives <komi...@gmail.com> wrote:
Ray, thanks so much for putting this together!  I had no issues downloading and installing Cantera, but I'm having issues with the Matlab installation.  After installing with brew install cantera --with-matlab=/Applications/MATLAB_R2014a.app/  there appears to be no additions to the matlab toolboxes in the Matlab app bundle.

--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.

Jeffrey Komives

unread,
Oct 2, 2014, 1:40:45 PM10/2/14
to canter...@googlegroups.com
Thanks for the response!!  What ended up working for me was creating a symbolic link to /usr/local/Cellar/cantera/2.1.2/lib/python2.7/site-packages/cantera in /Documents/MATLAB and then adding that link to the path.  Since MATLAB maintains its own Python paths, this also resolved the Python issues when using the toolbox.  Worked like a charm!

Christopher Wiacek

unread,
Oct 16, 2014, 1:34:14 AM10/16/14
to canter...@googlegroups.com
This is fantastic. The only thing that did not work for me was that I had to manually move my files from:

/usr/local/Celler/cantera/2.1.2/lib

to:

HD/ Library/Python/2.7/site-packages

in order to be able to import the canter package within python and python. I'm a bit of a newb with installing things like this and am required to use cantera for a graduate course. This might be obvious to some of you- YMMV, etc.

Jeff Komives

unread,
Oct 16, 2014, 9:42:11 AM10/16/14
to canter...@googlegroups.com
You could also edit one of the Python .pth files to tell Python to look in the appropriate directory.  Here’s what worked for me:

1.     Run: cd /usr/local/lib/python2.7/site-packages

2.     Open or create Extras.pth in this location and add the following line

a.     /usr/local/Cellar/cantera/2.1.2/lib/python2.7/site-packages/cantera

I created a How-To incorporating Ray’s instructions and a few follow-on steps to integrate into MATLAB for a course at my institution.  This may help people as well.

-Jeff
How to install Cantera on a Mac v5a.pdf

Alberto

unread,
Mar 19, 2015, 10:48:57 AM3/19/15
to canter...@googlegroups.com

Hi Ray,

my name is Alberto and I’m new on this group. I have decided to write over here because I would like to install Cantera on my Mac (Mavericks OSX 10.9.5) in order to use it with MatlabR2013a. Unfortunately, I’m not an expert in using the terminal (actually I’m a pretty new user of a Mac OSX as well) and I would need some help.

I searched something on the web trying to understand how to get Cantera and install it but so far I have found only some confusing instructions. Actually, I have realized I would need some step-by-step guidelines to figure out with the installation.

In particular, I have found this google group where you posted a sequence of steps that should be useful in order to finalize Cantera installation. Even though I followed your instructions, I was not able to complete the sequence. Specifically, I’m not sure about the definition of the paths/directories; basically, what I mean is that I think my problems are related to the correct use/set of the directories.

In conclusion, I would kindly ask if you could send me a detailed description of the steps that I have to follow, specifying the commands that I have to write on the terminal window as well as underling the name of the path/s I have to put.

I hope you could help me.

Thank you very much

Best Regards

Alberto

Bryan W. Weber

unread,
Mar 19, 2015, 1:18:01 PM3/19/15
to canter...@googlegroups.com
Dear Alberto,


Look carefully, there are several similar looking instructions that might have some mistakes. If those don't work, can you please tell us the specific error that you see when you try to run a particular command?

Best,
Bryan

Steven C. DeCaluwe

unread,
Mar 19, 2015, 4:33:54 PM3/19/15
to canter...@googlegroups.com
Dear Alberto,

The Homebrew option worked very well for me, and for the students in my graduate class who were on macs. 

If the instructions at Bryan's link don't work, let me know. I might have some slight modifications that worked on my system

Sent from my iPad

ischoegl

unread,
Mar 19, 2015, 6:56:47 PM3/19/15
to canter...@googlegroups.com
Dear Alberto,

My students had some trouble with installations as well (see https://code.google.com/p/cantera/issues/detail?id=254&can=1&q=ischoegl).

There are some new instructions that are much improved here:
https://github.com/Cantera/cantera/blob/doc-work/doc/sphinx/install.rst

Hope this helps,
-ingmar-

Alberto

unread,
Mar 23, 2015, 10:11:16 AM3/23/15
to canter...@googlegroups.com
Dear all, 

Thanks a lot for your suggestions. I followed the instructions mentioned here: http://cantera.github.io/dev-docs/sphinx/html/install.html#mac-os-x (Bryan's link) but unfortunately I still had some problems. Specifically, the procedure stopped during the "sons test". The following message appeared:

scons: *** [test_problems/finish_tests] One or more tests failed.

scons: building terminated because of errors.


Do you have some ideas to fix this issue? 

Thank you for your helpfulness 
Alberto

P.S.: 1) I have updated the OS X to Yosemite before going ahead with the Cantera's installation. 2) I attached the "terminal page" where all the steps I did are reported (in case these could help).
Terminal workspace.pdf

Ray Speth

unread,
Mar 23, 2015, 11:41:40 AM3/23/15
to canter...@googlegroups.com
Alberto,

According to the log, the Matlab test (and possibly others) failed. Can you confirm that /Applications/MATLAB_R2013a.app is where Matlab is installed on our system? If that is the correct path, please run the command:

brew install -v cantera --HEAD --with-matlab=/Applications/MATLAB_R2013a.app/

(same as what you used before with the addition of the "-v" flag for "verbose") and post the output, which will contain a more detailed log of what tests succeeded and failed.

Regards,
Ray

Alberto

unread,
Mar 23, 2015, 11:59:22 AM3/23/15
to canter...@googlegroups.com
Hi Ray, 

I think that /Applications/MATLAB_R2013a.app is where Matlab is installed on my system. Basically, it is in the same folder/location of all the other applications typically installed in my Mac, namely in: Macintosh/Applications/ However, if you can suggest how I can check this aspect via terminal commands, please let me know. 

I run the command you suggested. I attach the log file. 

Best Regards
Alberto
Terminal workspace_v2.pdf

Ray Speth

unread,
Mar 23, 2015, 12:24:27 PM3/23/15
to canter...@googlegroups.com
Alberto,

Well, the problem isn't the Matlab path, as Cantera is at least able to start the Matlab tests. I'm surprised by the error though, as I don't think a shared object version of 3.0.0 even exists for Sundials, so nothing should be looking for it. Have you ever installed another copy of Sundials besides the one that you installed using Homebrew? Can you run the following command and show its output:

find / -name libsundials_cvodes* 2>/dev/null

Regards,
Ray

Alberto

unread,
Mar 23, 2015, 1:43:50 PM3/23/15
to canter...@googlegroups.com
To the best of my knowledge I have never installed Sundials before. I mean, if any type of installation process concerning other program that I have installed did the installation of Sundials automatically, I did not do  it previously. 

I run the command you suggested. Here the output:

iMac-di-Alberto:~ Alberto$ find / -name libsundials_cvodes* 2>/dev/null

/Applications/MATLAB_R2013a.app/bin/maci64/libsundials_cvodes.2.0.0.dylib

/Applications/MATLAB_R2013a.app/bin/maci64/libsundials_cvodes.2.dylib

/Applications/MATLAB_R2013a.app/bin/maci64/libsundials_cvodes.dylib

/usr/local/Cellar/sundials/2.5.0/lib/libsundials_cvodes.2.0.0.dylib

/usr/local/Cellar/sundials/2.5.0/lib/libsundials_cvodes.2.dylib

/usr/local/Cellar/sundials/2.5.0/lib/libsundials_cvodes.a

/usr/local/Cellar/sundials/2.5.0/lib/libsundials_cvodes.dylib

/usr/local/lib/libsundials_cvodes.2.0.0.dylib

/usr/local/lib/libsundials_cvodes.2.dylib

/usr/local/lib/libsundials_cvodes.a

/usr/local/lib/libsundials_cvodes.dylib

iMac-di-Alberto:~ Alberto$ 


Kind Regards
Alberto 

Ray Speth

unread,
Mar 23, 2015, 5:15:44 PM3/23/15
to canter...@googlegroups.com
Alberto,

What is the output of the following two commands:

otool -L /usr/local/lib/libsundials_cvodes.2.dylib

otool
-L /Applications/MATLAB_R2013a.app/bin/maci64/libsundials_cvodes.2.dylib

It looks like you have two copies of Sundials installed that are not exactly the same (the one in /usr/local/lib is a link to the one in /usr/local/Cellar, which is installed by Homebrew). I don't know what put the copies that are in /Applications/MATLAB_R2013a.app/bin/maci64 there, but those are not part of Matlab, at least to my knowledge. I hesitate to suggest removing them, since I don't know what it would break (some other Matlab toolbox you have installed, I guess) but it would probably fix this problem with using the Cantera Matlab toolbox.

Regards,
Ray

Alberto

unread,
Mar 23, 2015, 5:33:01 PM3/23/15
to canter...@googlegroups.com
Hi Ray,

In the meantime I tried to update my MatLab version so I uninstalled MATLAB_R2013a and I installed MATLAB_R2014b. Afterwards I tried to perform the same procedure as before to install Cantera but the same problems hold. 
I run the commands you suggested as well. The output are reported below:

iMac-di-Alberto:~ Alberto$ otool -L /usr/local/lib/libsundials_cvodes.2.dylib

/usr/local/lib/libsundials_cvodes.2.dylib:

/usr/local/lib/libsundials_cvodes.2.dylib (compatibility version 3.0.0, current version 3.0.0)

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

iMac-di-Alberto:~ Alberto$ otool -L /Applications/MATLAB_R2014b.app/bin/maci64/libsundials_cvodes.2.dylib

/Applications/MATLAB_R2014b.app/bin/maci64/libsundials_cvodes.2.dylib:

@rpath/libsundials_cvodes.2.dylib (compatibility version 2.0.0, current version 2.0.0)

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

iMac-di-Alberto:~ Alberto$ 


What do you suggest I can do to fix the issue?

Thanks a lot
Alberto

Ray Speth

unread,
Mar 24, 2015, 3:40:56 PM3/24/15
to canter...@googlegroups.com
Alberto,

The problem is that you have two different versions of Sundials installed: The one installed using Homebrew, that Cantera is built to use, in /usr/local/lib, and another copy, incompatible with Cantera, that is installed inside your copy of Matlab. The problem is that when you use Cantera from within Matlab, it sees this other copy of the library first. I don't know what Matlab toolbox that those Sundials libraries are a part of, but if you can install it without that toolbox, that should fix the problem. Another option would be to force Cantera to use the static versions of the Sundials libraries, which would keep it from finding the copies installed with Matlab, by removing the shared versions installed by Homebrew, e.g.:

rm /usr/local/lib/libsundials_*.dylib

After installing Cantera, you can restore the removed links by running:

brew unlink sundials && brew link sundials

Regards,
Ray

Alberto

unread,
Apr 7, 2015, 5:31:05 AM4/7/15
to canter...@googlegroups.com
Hi Ray,

Thank you very much for your suggestions and my apologize for the late in my answer. 
 
Finally, I removed the Sundials libraries inside my copy of Matlab, just living those ones installed by Cantera and everything now seems to work.

Thank you again for your helpfulness.

Best Regards
Alberto 

guangying yu

unread,
Sep 17, 2015, 3:29:12 PM9/17/15
to Cantera Users' Group
Dear Ray,

When I tried to install cantera with Matlab tools, it said
"scons: *** [build/test/matlab/runCanteraTests.m.passed] /private/tmp/cantera20150916-9695-qmy6is/test/work/matlab-results.txt: No such file or directory
scons: building terminated because of errors."

So I tried just to install cantera and then it worked, except the directory is /usr/local/Cellar/cantera/HEAD/lib/python/site-packages/cantera. Then I tried to install it again with Matlab tools, but it warned me that 

homebrew/science/cantera-HEAD already installed. It seems I have to uninstall and then install it again.


How should I solve the Matlab toolbox problem? Thank you!


Sincerely,

Guangying

Ray Speth

unread,
Sep 22, 2015, 1:19:55 PM9/22/15
to Cantera Users' Group
Guangying,

If you want to install with different options, then yes, you have to uninstall and reinstall. That is (as far as I understand) part of how Homebrew works.

As far as the Matlab issue goes, that error implies that the Matlab test failed to run, in which case you should try running 'brew install' with the '--verbose
 option and looking for more information at the point where the Matlab test is supposed to run. It would not surprise me if the problem you were experiencing was the same as the one discussed in this thread, in which case my recommended solution remains to remove the Sundials dynamic libraries before installing Cantera to avoid conflicts with the ones bundled with Matlab.

Regards,
Ray

guangying yu

unread,
Oct 23, 2015, 5:44:26 PM10/23/15
to Cantera Users' Group
Hi Ray,

Is there any option command for the Fortran 90 interface in the installation? When I use homebrew to install Cantera, it always returns:

==> Installing cantera from homebrew/homebrew-science

==> Cloning https://github.com/cantera/cantera.git

Updating /Library/Caches/Homebrew/cantera--git

==> Checking out branch master

Synchronizing submodule url for 'breathe'

Synchronizing submodule url for 'doc/sphinx-bootstrap-theme'

==> Downloading https://pypi.python.org/packages/source/C/Cython/cython-0.22.tar.gz

Already downloaded: /Library/Caches/Homebrew/cantera--Cython-0.22.tar.gz

==> python -c import setuptools... --no-user-cfg install --prefix=/private/tmp/cantera20151023-26332-1jaqj1a/cython --single-version-externally-managed --record=installed.txt

==> /usr/local/opt/scons/bin/scons build prefix=/usr/local/Cellar/cantera/HEAD python_package=full CC=/usr/bin/clang CXX=/usr/bin/clang++ f90_interface=n matlab_path=/Applications/MATLAB_R2015a.app/ python3_package=n


The fortran option'f90_interface=n' is always N. How can I change it?


Thank you!

Ray Speth

unread,
Oct 23, 2015, 6:43:15 PM10/23/15
to Cantera Users' Group
Guangying,

No, there is no option to install the F90 interface when using Homebrew. To build the F90 interface, you will need to follow the more general compilation instructions which will allow you to customize other settings as well, which will almost certainly be necessary in this case. To the best of my knowledge, the F90 interface has not been tested at all on OS X. At a minimum, you will probably need to specify the C and C++ compilers to use ones that are compatible with whatever Fortran compiler you are trying to use.

Honestly, I would discourage you from using the Fortran interface in all but an extremely small number of circumstances. The C++, Python, and Matlab interfaces are much more complete, better documented, easier to use, and most of the time just as fast (since all of the computationally intensive work is being done in the C++ code no matter what).

Regards,
Ray

guangying yu

unread,
Oct 26, 2015, 5:37:52 PM10/26/15
to Cantera Users' Group
Hi Ray,

Thank you for your advice. Python and Matlab interface is really better than the fortran one. I would like to use these two interface. But I still have the matlab toolbox problem that I asked in the previous post. I tried to remove the libsundials*.dylib and run 
$ brew install
The problem still exists. I attached the informations given by the -v option.

Thank you!
Guangying
Homebrew install -v.txt

Ray Speth

unread,
Oct 29, 2015, 10:21:34 PM10/29/15
to Cantera Users' Group
Guangying,

Unfortunately it looks like the Matlab test is failing without generating any output, which makes it difficult to diagnose the problem. Can you try installing without running the test suite, by passing the '--without-check' to the 'brew install' command? Then, if you try to use the Matlab toolbox, I would be curious to see if it at least gives you some error information.

Regards,
Ray
Reply all
Reply to author
Forward
0 new messages