在 google colab 中导入 cantera(包)不起作用
我无法解决以下问题: 对于我的研究,我想使用 Google Colab 笔记本来执行数据分析。 为此,我需要一个包(cantera),它只能使用conda安装。 我可以做到这一点,但是每次启动 colab 笔记本时,我都需要重新安装所有软件包,这需要花费很多时间。因为我想避免这种情况,所以我遵循了此链接中描述的过程: https:// /dvij-kalaria.medium.com/how-to-make-load-save-a-conda-environment-in-google-colab-jupyter-322801aad486。
目标是:
- 创建一个包含所有所需包的环境一次。 [create_environment.ipynb]
- 将这些包以 .zip 格式导出到我的谷歌驱动器。
- 将包含包的 .zip 文件解压到新的 colab 笔记本中。 [main_file]
- 使用所需的包运行笔记本。
当执行这些步骤时,它将显示错误:
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 ---------------
***********************************************************************
如果我运行包含以下内容的代码单元格:
!pip show cantera
我得到以下输出:
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:
指示已找到 cantera 包。
在我的 Github 页面上可以找到复制问题的文件 (.ipynb): 文件.zip
我真的希望有人能帮助我解决这个问题!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论