.cti file format Cantera run error

642 views
Skip to first unread message

Nikhil Balasubramanian

unread,
Jun 20, 2018, 10:58:47 AM6/20/18
to Cantera Users' Group
Hi, 

I have been using Cantera in Anaconda environment for a while now. Until now, I had been using gri30.xml as my mechanism file and there hasn't been any issues. I tried using a new mechanism in .cti format and Cantera throws an error { ModuleNotFoundError: No module named 'cantera'.} It's strange as I have been using Cantera for some time, but only used gri30 mechanism in .xml file format. 

(P.S. I already tried uninstalling and reinstalling Cantera. Did not help.)

Thanks in advance, 

Best, 
Nikhil 

Nikhil Balasubramanian

unread,
Jun 22, 2018, 11:31:04 AM6/22/18
to Cantera Users' Group
Update: I converted the .cti mechanism to .xml and it works fine. Still cannot figure out why using a .cti mechanism file gives me an error.

Steven DeCaluwe

unread,
Jun 22, 2018, 12:02:32 PM6/22/18
to canter...@googlegroups.com
Hi Nikhil,

Loading a cti file invokes the Python interpreter to convert it to ctml (loading xml skips this), and it looks like it is somehow not on your path?

But this doesn’t make sense; I feel like none of the Cantera functionality would work, were this the case. 

Could you have forgotten to activate the proper conda environment?

Can you send
a. The  fact command used to install Cantera, and 
b. The exact line of code leading to the error?

Thanks,
Steven

Sent from my iPhone
--
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.

Nikhil Balasubramanian

unread,
Jun 23, 2018, 11:44:25 AM6/23/18
to Cantera Users' Group

Hi Dr. Steven, 

I installed Cantera through Anaconda by defining a new environment named spam and used the command as given in the installation document. 

C:\Users\nikhil.b>activate spam

(spam) C:\Users\nikhil.b>conda list
# packages in environment at C:\Users\nikhil.b\AppData\Local\New folder\envs\spam:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.10           py36hcd07829_0
asn1crypto                0.24.0                   py36_0
astroid                   1.6.4                    py36_0
babel                     2.6.0                    py36_0
backcall                  0.1.0                    py36_0
bleach                    2.1.3                    py36_0
ca-certificates           2018.03.07                    0
cantera                   2.3.0               np113py36_2    cantera

The error obtained is as follows: 

CanteraError: 
***********************************************************************
CanteraError thrown by ct2ctml_string:
Error converting input file "./42_species_skeletal_mechanism.cti" to CTML.
Python command was: 'C:\Users\nikhil.b\AppData\Local\New folder\pkgs\python-3.6.4-h6538335_1\python.exe'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\python36.zip', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\DLLs', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\lib', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\lib\\site-packages']

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ModuleNotFoundError: No module named 'cantera'
--------------- end of converter log ---------------
***********************************************************************

This error is observed only when I run mechanisms in .cti format. 

Thanks, 

Nikhil 

Bryan W. Weber

unread,
Jun 23, 2018, 6:30:57 PM6/23/18
to Cantera Users' Group
Nikhil,

That is indeed very confusing. It looks like the version of Python that's picked up is not the right Python executable. Which version of conda are you running? Can you use conda activate spam instead of just activate spam? How did you install Anaconda? That looks like a non-standard install directory for Anaconda. How are you importing Cantera in your Python interpreter? Are you using IPython, and if so, did you install that in your environment as well?

Best,
Bryan

Nikhil Balasubramanian

unread,
Jun 24, 2018, 4:49:16 AM6/24/18
to Cantera Users' Group
Hi Bryan, 

Yes, It is. It maybe the source of my other problems as maybe some functions might not be called in correctly. Do you think its better to uninstall everything  (conda, cantera) and try again? 

Here are the replies to the queries you asked for,
  • 4.4.10.
  • Tried it and it activates spam as before.
  • Through the executable file from their website. It is installed in "C:\Users\nikhil.b\AppData\Local\Continuum\anaconda3" which I think was the default installation folder. 
  • I am using Spyder and it is installed in the same environment as well.
I hope it helps,

Thanks, 

Nikhil 

Bryan W. Weber

unread,
Jun 24, 2018, 3:59:54 PM6/24/18
to Cantera Users' Group
Do you get the same error after using conda activate? If so, can you paste the output of conda config --show?

Best,
Bryan

Steven DeCaluwe

unread,
Jun 24, 2018, 5:38:27 PM6/24/18
to canter...@googlegroups.com
I generally use python from command line or in a script file, so I’m not terribly acquainted with Spyder, but do I understand correctly that you’re activating your conda environment *after* you open up Spyder?  

This may be at the root of it. Spyder is not looking anywhere in you conda install folders for python. 

Can you try just running python from command line, after activating conda,  and just execute the ct.Solution line to see if it works from there?

Steven

Sent from my iPhone

Nikhil Balasubramanian

unread,
Jun 25, 2018, 3:52:44 AM6/25/18
to Cantera Users' Group
Hi Bryan, 

Yes, I got the same error. 

C:\Users\nikhil.b>conda config --show
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
  - ca-certificates
  - certifi
  - openssl
allow_non_channel_urls: True
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_update_conda: True
changeps1: True
channel_priority: True
channels:
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
create_default_packages: []
custom_channels:
custom_multichannels:
  local: []
default_channels:
disallow: []
download_only: False
envs_dirs:
  - C:\Users\nikhil.b\AppData\Local\New folder\envs
  - C:\Users\nikhil.b\AppData\Local\conda\conda\envs
  - C:\Users\nikhil.b\.conda\envs
force: False
json: False
local_repodata_ttl: 1
migrated_channel_aliases: []
no_dependencies: False
non_admin_enabled: True
notify_outdated_conda: True
offline: False
override_channels_enabled: True
path_conflict: clobber
pinned_packages: []
pkgs_dirs:
  - C:\Users\nikhil.b\AppData\Local\New folder\pkgs
  - C:\Users\nikhil.b\AppData\Local\conda\conda\pkgs
proxy_servers: {}
quiet: False
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
report_errors: None
rollback_enabled: True
safety_checks: warn
shortcuts: True
show_channel_urls: None
ssl_verify: True
track_features: []
use_index_cache: False
use_pip: True
verbosity: 0
whitelist_channels: []

Thanks, 
Nikhil 

Nikhil Balasubramanian

unread,
Jun 25, 2018, 4:03:30 AM6/25/18
to Cantera Users' Group
Hi Dr.Steven,

Yes, I am activating spyder from within spam. I tried the same from the command line and it gives me the same error. 


(base) C:\Users\nikhil.b>activate spam

(spam) C:\Users\nikhil.b> ipython
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cantera as ct

In [2]: gas=ct.Solution('gri30.cti')
---------------------------------------------------------------------------
CanteraError                              Traceback (most recent call last)
<ipython-input-2-c95969fc90d1> in <module>()
----> 1 gas=ct.Solution('gri30.cti')

interfaces\cython\cantera\base.pyx in cantera._cantera._SolutionBase.__cinit__ (interfaces\cython\cantera\_cantera.cpp:7873)()

interfaces\cython\cantera\base.pyx in cantera._cantera._SolutionBase._init_cti_xml (interfaces\cython\cantera\_cantera.cpp:8273)()

CanteraError:
***********************************************************************
CanteraError thrown by ct2ctml_string:
Error converting input file "C:\Users\nikhil.b\AppData\Local\New folder\envs\spam\lib\site-packages\cantera\data/gri30.cti" to CTML.
Python command was: 'C:\Users\nikhil.b\AppData\Local\New folder\pkgs\python-3.6.4-h6538335_1\python.exe'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\python36.zip', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\DLLs', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\lib', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\lib\\site-packages']

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ModuleNotFoundError: No module named 'cantera'
--------------- end of converter log ---------------
*********************************************************************** 

In [3]: gas=ct.Solution('gri30.xml')

In [4]: gas()

  gri30:

       temperature             300  K
          pressure          101325  Pa
           density       0.0818891  kg/m^3
  mean mol. weight         2.01588  amu

                          1 kg            1 kmol
                       -----------      ------------
          enthalpy           26470        5.336e+04     J
   internal energy     -1.2109e+06       -2.441e+06     J
           entropy           64914        1.309e+05     J/K
    Gibbs function     -1.9448e+07        -3.92e+07     J
 heat capacity c_p           14312        2.885e+04     J/K
 heat capacity c_v           10187        2.054e+04     J/K

                           X                 Y          Chem. Pot. / RT
                     -------------     ------------     ------------
                H2              1                1         -15.7173
     [  +52 minor]              0                0


Thanks, 

Nikhil 

Steven DeCaluwe

unread,
Jun 25, 2018, 7:37:56 AM6/25/18
to canter...@googlegroups.com
Hi Nikhil,

Please try this with python from the command line, rather than iPython. 

I think there is a workaround where you explicitly add the anaconda python to you path, but I’d also like t figure out why this is happening. 

Thanks,
Steven 

Sent from my iPhone

Nikhil Balasubramanian

unread,
Jun 25, 2018, 7:44:39 AM6/25/18
to Cantera Users' Group
Hi Dr. Steven, 

I tried as you suggested, but it still gives me the same error. 


(base) C:\Users\nikhil.b>activate spam

(spam) C:\Users\nikhil.b>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cantera as ct
>>> gas=ct.Solution('gri30.cti')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "interfaces\cython\cantera\base.pyx", line 29, in cantera._cantera._SolutionBase.__cinit__ (interfaces\cython\cantera\_cantera.cpp:7873)
  File "interfaces\cython\cantera\base.pyx", line 50, in cantera._cantera._SolutionBase._init_cti_xml (interfaces\cython\cantera\_cantera.cpp:8273)
cantera._cantera.CanteraError:
***********************************************************************
CanteraError thrown by ct2ctml_string:
Error converting input file "C:\Users\nikhil.b\AppData\Local\New folder\envs\spam\lib\site-packages\cantera\data/gri30.cti" to CTML.
Python command was: 'C:\Users\nikhil.b\AppData\Local\New folder\pkgs\python-3.6.4-h6538335_1\python.exe'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\python36.zip', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\DLLs', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\lib', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1', 'C:\\Users\\nikhil.b\\AppData\\Local\\New folder\\pkgs\\python-3.6.4-h6538335_1\\lib\\site-packages']

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ModuleNotFoundError: No module named 'cantera'
--------------- end of converter log ---------------
***********************************************************************

>>> gas=ct.Solution('gri30.xml')
>>> gas()

  gri30:

       temperature             300  K
          pressure          101325  Pa
           density       0.0818891  kg/m^3
  mean mol. weight         2.01588  amu

                          1 kg            1 kmol
                       -----------      ------------
          enthalpy           26470        5.336e+04     J
   internal energy     -1.2109e+06       -2.441e+06     J
           entropy           64914        1.309e+05     J/K
    Gibbs function     -1.9448e+07        -3.92e+07     J
 heat capacity c_p           14312        2.885e+04     J/K
 heat capacity c_v           10187        2.054e+04     J/K

                           X                 Y          Chem. Pot. / RT
                     -------------     ------------     ------------
                H2              1                1         -15.7173
     [  +52 minor]              0                0

Thanks, 

Nikhil 

Bryan W. Weber

unread,
Jun 26, 2018, 11:15:05 AM6/26/18
to Cantera Users' Group
Nikhil,

Did you add the configuration to move the environment to the "New Folder"? If so, did you have a reason to do that? If you did not, or do not, I would suggest removing those configuration options and recreating the environment.

Best,
Bryan

Nikhil Balasubramanian

unread,
Jun 27, 2018, 10:24:01 AM6/27/18
to Cantera Users' Group
Hi Bryan, 

I did not create it on purpose, I'm guessing it got automatically created. All of Anaconda's files are in the New Folder. If I just copy all the other files(spyder, conda, continuum etc.) into New Folder.  

P.S. Please check the images. I understand that screenshots aren't the best way to post information here, but I couldn't find a better way to post it. 

Thanks, 

Nikhil 
cantera 2.png
cantera1.png
Reply all
Reply to author
Forward
0 new messages