Unable to run cantera in both matlab and python environment on windows 10

3,944 views
Skip to first unread message

Priybrat Sharma

unread,
Aug 8, 2015, 10:36:37 AM8/8/15
to Cantera Users' Group
I am getting these error running cantera , I have tried everything listed on previous threads like setting environment variable, installing numpy again etc-era

In matlab --------------->

Error using ctmethods


************************************************
                Cantera Error!
************************************************


Procedure: ct2ctml_string
Error:   Error converting input file "C:\Cantera\data/gri30.cti" to CTML.
Python command was: 'C:\Python34\python.exe'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', 'C:\\Cantera\\bin', 'C:\\Python34', 'C:\\Windows\\SYSTEM32\\python34.zip',
'C:\\Python34\\DLLs', 'C:\\Python34\\lib', 'C:\\Python34\\lib\\site-packages']

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

Error in XML_Node (line 20)
    x.id = ctmethods(10, 15, 0, src);

Error in Solution (line 47)
doc = XML_Node('doc', src);

Error in GRI30 (line 33)
    s = Solution('gri30.cti', 'gri30');


##############################################################################
In Python

>>> import cantera
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'cantera'
>>> gas = cantera.Solution('gri30.cti')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'cantera' is not defined
>>> h2o = cantera.PureFluid('liquidvapor.cti', 'water')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'cantera' is not defined
>>> import Cantera
>>> gas = Cantera.Solution('gri30.cti')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cantera\base.pyx", line 26, in cantera._cantera._SolutionBase.__cinit__ (interfaces\cython\cantera\_cantera.cpp:6758)
  File "cantera\base.pyx", line 47, in cantera._cantera._SolutionBase._init_cti_xml (interfaces\cython\cantera\_cantera.cpp:7126)
RuntimeError:
***********************************************************************
CanteraError thrown by ct2ctml_string:
Error converting input file "C:\Python34\lib\site-packages\Cantera\data/gri30.cti" to CTML.
Python command was: 'C:\Python34\python.exe'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', 'C:\\Cantera\\bin', 'C:\\Python34', 'C:\\Windows\\SYSTEM32\\python34.zip', 'C:\\Python34\\DLLs', 'C:\\Python34\\lib', 'C:\\Python34\\lib\\site-packages']

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

In python import and commands works only with capital C in cantera

Bryan W. Weber

unread,
Aug 8, 2015, 1:31:51 PM8/8/15
to Cantera Users' Group
Hello,

It looks like you're using an older version of Cantera. Which version of Cantera did you install or do you have installed?

Best regards,
Bryan

Priybrat Sharma

unread,
Aug 8, 2015, 2:50:11 PM8/8/15
to Cantera Users' Group

I am using Cantera-2.2.0-x64 and Cantera-Python-2.2.0-x64-py3.4 along with numpy-1.10.0b1, all correct versions installed but can't figure out what is wrong with installations. Special the part python commands working with only capital C in cantera.

Any suggestion how to deal with this ..

Nick Curtis

unread,
Aug 10, 2015, 5:09:17 PM8/10/15
to Cantera Users' Group
Make sure:
  • you're using python3
  • There's no old Cantera folder in your site-packages folder (you might want to delete all of them and reinstall)

Nick

Ray Speth

unread,
Aug 10, 2015, 6:31:35 PM8/10/15
to Cantera Users' Group
I don't understand how you got a folder named "Cantera" with a capital C in your Python 3.4 site-packages directory. The legacy Cantera Python module, which only ever existed for Python 2.x, had this name. I would be interested in seeing the output of the following commands in Python, which might shed some light on what's happening here:

import sys
print(sys.version_info)
print(sys.executable)
import Cantera
print(Cantera.__file__)
print(dir(Cantera))
print(Cantera.__version__)

Regards,
Ray

Priybrat Sharma

unread,
Aug 10, 2015, 11:31:10 PM8/10/15
to Cantera Users' Group
Hello,

Yeah Nick I tried doing that twice, deleting the old folders and reinstalling, I am using Python 3.4.x varient.

Rey on the running the commands suggested I am getting these outputs
>>> import sys
>>> print(sys.version_info)
sys
.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
>>> print(sys.executable)
C
:\Python34\python.exe
>>> import Cantera
>>> print(Cantera.__file__)
C
:\Python34\lib\site-packages\Cantera\__init__.py
>>> print(dir(Cantera))
['Arrhenius', 'AxisymmetricStagnationFlow', 'Boundary1D', 'BurnerFlame', 'CarbonDioxide', 'ChebyshevReaction', 'ChemicallyActivatedReaction', 'ConstPressureReactor', 'ConstantCp', 'CounterflowDiffusionFlame', 'CounterflowPremixedFlame', 'Domain1D', 'DustyGas', 'DustyGasTransport', 'ElementaryReaction', 'Falloff', 'FalloffReaction', 'FlameBase', 'FlowDevice', 'FlowReactor', 'FreeFlame', 'FreeFlow', 'Func1', 'GasTransportData', 'Heptane', 'Hfc134a', 'Hydrogen', 'IdealGasConstPressureReactor', 'IdealGasReactor', 'ImpingingJet', 'Inlet1D', 'Interface', 'InterfaceKinetics', 'InterfacePhase', 'InterfaceReaction', 'Kinetics', 'MassFlowController', 'Methane', 'Mixture', 'NasaPoly2', 'Nitrogen', 'Outlet1D', 'OutletReservoir1D', 'Oxygen', 'PlogReaction', 'PressureController', 'PureFluid', 'ReactingSurface1D', 'Reaction', 'ReactionPathDiagram', 'Reactor', 'ReactorBase', 'ReactorNet', 'Reservoir', 'ShomatePoly2', 'Sim1D', 'Solution', 'Species', 'SpeciesThermo', 'SriFalloff', 'Surface1D', 'SymmetryPlane1D', 'ThermoPhase', 'ThreeBodyReaction', 'Transport', 'TroeFalloff', 'Valve', 'Wall', 'WallSurface', 'Water', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__sundials_version__', '__version__', '_cantera', 'add_directory', 'add_module_directory', 'appdelete', 'avogadro', 'boltzmann', 'electron_charge', 'electron_mass', 'epsilon_0', 'erf', 'faraday', 'gas_constant', 'import_phases', 'interrupts', 'light_speed', 'liquidvapor', 'math', 'np', 'one_atm', 'onedim', 'os', 'permeability_0', 'planck', 'stefan_boltzmann', 'sys', 'utils', 'warnings']
>>> print(Cantera.__version__)
2.2.0
>>>
>>>

I am not messing around with in installer at all, just went with default what windows is doing.

Priybrat Sharma

unread,
Aug 10, 2015, 11:52:58 PM8/10/15
to Cantera Users' Group
I also tried using import Cantera as cantera, but then it's throwing in the same error as matlab.

>>> import Cantera as cantera
>>> gas = cantera.Solution('gri30.cti')
Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>

 
File "cantera\base.pyx", line 26, in cantera._cantera._SolutionBase.__cinit__ (interfaces\cython\cantera\_cantera.cpp:6758)
 
File "cantera\base.pyx", line 47, in cantera._cantera._SolutionBase._init_cti_xml (interfaces\cython\cantera\_cantera.cpp:7126)
RuntimeError:
***********************************************************************
CanteraError thrown by ct2ctml_string:
Error converting input file "C:\Python34\lib\site-packages\Cantera\data/gri30.cti" to CTML.
Python command was: 'C:\Python34\python.exe'
The exit code was: 1
-------------- start of converter log --------------
sys
.path: ['', 'C:\\Cantera\\bin', 'C:\\Python34', 'C:\\Windows\\SYSTEM32\\python34.zip', 'C:\\Python34\\DLLs', 'C:\\Python34\\lib', 'C:\\Python34\\lib\\site-packages']

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

Bryan W. Weber

unread,
Aug 11, 2015, 6:17:29 AM8/11/15
to Cantera Users' Group
Dear Priybrat,

From where are you downloading the installers? You should not have a Cantera (capital C) package at all... that's why we're all confused :-)

Can you please show the output of 

import sys
print(sys.path)

Best,
Bryan

Ray Speth

unread,
Aug 11, 2015, 10:57:10 AM8/11/15
to Cantera Users' Group
Priybrat,

Can you please try the following?

1) Uninstall all versions of the Cantera Python module.
2) Remove the folder C:\Python34\lib\site-packages\Cantera if it still exists
3) Reinstall the Cantera 2.2.0 Python module for Python 3.4
4) Confirm that the folder C:\Python34\lib\site-packages\cantera is named with a lowercase 'c'

Regards,
Ray

Priybrat Sharma

unread,
Aug 11, 2015, 10:58:27 AM8/11/15
to Cantera Users' Group

Hey Bryan

I downloaded every thing from official websites following the tutorial from cantera GitHub page
http://cantera.github.io/docs/sphinx/html/install.html

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', 'C:\\Python34', 'C:\\Windows\\SYSTEM32\\python34.zip', 'C:\\Python34\\DLLs', 'C:\\Python34\\lib', 'C:\\Python34\\lib\\site-packages']
>>>

I am installing cantera for first time, so I really don't know how print(sys.path) is suppose to look.

Regards,
Priybrat

Bryan W. Weber

unread,
Aug 11, 2015, 11:33:51 AM8/11/15
to Cantera Users' Group
Dear Priybrat,

That looks correct to me. Please try what Ray suggested and see if it fixes the problem. Can you please also make sure that everything is the same "bitness", either x86 (32-bit) or x64 (64-bit), including Python, Numpy, and Cantera? I don't think that is the problem because the Cantera installer should take care of it, but its good to check. Note that the default download from the python.org website is 32-bit, you have to specifically choose to download the 64-bit version.

Best,
Bryan
...

Priybrat Sharma

unread,
Aug 11, 2015, 12:18:43 PM8/11/15
to Cantera Users' Group
It Works now, Installed using the same packages but did just as Ray suggested, made the installation path to cantera instead of Cantera. Also, while installing python 3.4 selected add to path option which was unselected by default.

Now it works on both matlab and python.

Thank you everyone. ^_^

Just one more question, Is there any available script for IC engine type reactor with multiple zones, similar to one used in this paper (DOI: 10.1177/1468087413482480)

Regards,
Priybrat

MBP

unread,
Sep 21, 2017, 12:55:32 PM9/21/17
to Cantera Users' Group
I'm a bit new to Cantera, but I had similar problems stemming from the fact that I accidentally installed x86 cantera instead of x64. Make sure the system type matches, folks!
Reply all
Reply to author
Forward
0 new messages