'Importing cantera (package) in google colab not working
I am not able to solve the following problem: For my research I would like to use a Google Colab notebook to perform my data analysis. To this end I need a package (cantera), which could only be installed using conda. I am able to do this, however every time I start the colab notebook I need to reinstall all the packages again which takes a lot of time. Since I want to avoid this I followed a procedure described in this link: https://dvij-kalaria.medium.com/how-to-make-load-save-a-conda-environment-in-google-colab-jupyter-322801aad486.
The goal is to:
- create an environment with all the desired packages once. [create_environment.ipynb]
- export these packages in a .zip to my google drive.
- extract the .zip file containing the packages in a new colab notebook. [main_file]
- run the notebook with the desired packages.
When following these steps it will show an error:
CanteraError Traceback (most recent call last)
<ipython-input-5-9ed24c0ae5c4> in <module>()
1 import cantera as ct
----> 2 gas = ct.Solution('gri30.cti')
3
4 # Set reactants state
5 gas.TPX = 298, 101325, 'CH4:1, O2:2'
interfaces/cython/cantera/base.pyx in cantera._cantera._SolutionBase.__cinit__()
interfaces/cython/cantera/base.pyx in cantera._cantera._SolutionBase._init_cti_xml()
CanteraError:
***********************************************************************
CanteraError thrown by call_ctml_writer:
Error converting input file "/usr/local/lib/python3.7/site-packages/cantera/data/gri30.cti" to CTML.
Python command was: '/usr/bin/python3'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', '/env/python', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
ModuleNotFoundError: No module named 'cantera'
--------------- end of converter log ---------------
***********************************************************************
While if I run a code cell containing:
!pip show cantera
I get the following output:
Version: 2.5.1
Summary: The Cantera Python Interface
Home-page: https://cantera.org
Author: Raymond Speth
Author-email: [email protected]
License: UNKNOWN
Location: /usr/local/lib/python3.7/site-packages
Requires:
Required-by:
Indicating that the cantera package is found.
The files (.ipynb) to replicate the problem are found on my Github page: files.zip
I really hope someone can help me out on this one!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|