Cantera python keyword argument error

99 views
Skip to first unread message

Chris Neal

unread,
Mar 20, 2018, 1:04:14 PM3/20/18
to Cantera Users' Group
I'm trying to run this example: http://cantera.org/docs/sphinx/html/cython/examples/onedim_stagnation_flame.html

I'm seeing the following error pop up though:
Traceback (most recent call last):
  File "junk.py", line 54, in <module>
    sim = ct.ImpingingJet(gas=gas, width=width)
TypeError: __init__() got an unexpected keyword argument 'width'

It looks like that is a perfectly valid keyword argument. I can't quite figure out what I'm overlooking here. Any ideas?

Thanks,
Chris N.

Ray Speth

unread,
Mar 20, 2018, 1:09:52 PM3/20/18
to Cantera Users' Group
Chris,

What version of Cantera are you using? This works fine for me using both Cantera 2.3.0 and 2.4.0b1. The only reason I can think of that you would get that error is if you were using an out of date version of Cantera.

Regards,
Ray

Chris Neal

unread,
Mar 20, 2018, 1:20:15 PM3/20/18
to Cantera Users' Group
Looks like I am indeed using version '2.2.2b1'. I'm not sure why this is the default version of cantera that Python is using when I import the module. Is there a doc page about setting up the python environment to use a particular build(I have 2.3 built)?

Chris Neal

unread,
Mar 20, 2018, 1:52:47 PM3/20/18
to Cantera Users' Group
I cloned the newest version of the repo and did a:
scons build
sudo scons install

And the cantera version in Python3 seems to be up-to-date now at version 2.4. However when I try to import the cantera module in python2.7 I get the following error:

>>> import cantera as ct
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib64/python3.4/site-packages/cantera/__init__.py", line 4, in <module>
     from ._cantera import *
ImportError: No module named _cantera

I went back and use the python_package=full scons option to see if it would work, but I still see the module import error.


On Tuesday, March 20, 2018 at 1:09:52 PM UTC-4, Ray Speth wrote:

Chris Neal

unread,
Mar 20, 2018, 1:54:23 PM3/20/18
to Cantera Users' Group
System specs are:
LSB Version: n/a
Distributor ID: openSUSE project
Description: openSUSE Leap 42.3
Release: 42.3
Codename: n/a

Steven DeCaluwe

unread,
Mar 20, 2018, 1:58:10 PM3/20/18
to canter...@googlegroups.com
Hi Chris,

The two things that pop out to me:

1.  The underscore in front of the cantera module name seems odd.  I don’t have any insights, but wouldn’t expect to see that there.

2.  You are trying to import in python2.7, but the problematic line is called via the python3.4 interface.

Can you try running using python3?

Steven

——————————————————————————————————
Steven DeCaluwe, PhD
Assistant Professor of Mechanical Engineering
Colorado School of Mines
Brown Building W410B
Golden, CO 80401

Twitter: @DeCaluweGroup

--
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.
To post to this group, send email to canter...@googlegroups.com.
Visit this group at https://groups.google.com/group/cantera-users.
For more options, visit https://groups.google.com/d/optout.

Ray Speth

unread,
Mar 20, 2018, 2:04:21 PM3/20/18
to Cantera Users' Group

Chris,

I would suggest that managing Python’s search path is mainly a topic for the Python documentation, not the Cantera documentation.

I’m not sure how you’re getting a Python 3 directory on your Python 2 search path, unless there’s something that’s setting the PYTHONPATH environment variable. This can happen if you’re using the setup_cantera script — there is unfortunately no way to set this variable in a way that will work for both.

Regards,
Ray

Chris Neal

unread,
Mar 20, 2018, 2:09:32 PM3/20/18
to Cantera Users' Group
Ray,

You're correct. I was following the scons directions that are printed out after an installation, which included sourcing a setup script. When I don't source it, I can access the cantera module from Python2.7.

Cantera has been successfully installed.


File locations:


  applications                /usr/local/bin

  library files               /usr/local/lib64

  C++ headers                 /usr/local/include

  samples                     /usr/local/share/cantera/samples

  data files                  /usr/local/share/cantera/data  

  Python 2 package (cantera)  /usr/local/lib64/python2.7/site-packages

  Python 2 samples            /usr/local/lib64/python2.7/site-packages/cantera/examples  

  Python 3 package (cantera)  /usr/local/lib64/python3.4/site-packages

  Python 3 samples            /usr/local/lib64/python3.4/site-packages/cantera/examples

Setup scripts to configure the environment for Cantera are at:


  setup script (bash)         /usr/local/bin/setup_cantera

  setup script (csh/tcsh)     /usr/local/bin/setup_cantera.csh


It is recommended that you run the script for your shell by typing:


  source /usr/local/bin/setup_cantera


before using Cantera, or else include its contents in your shell login script.


scons: done building targets.

Reply all
Reply to author
Forward
0 new messages