You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Myokit PythonExporter导出模型遇NotImplementedError求助

问题:使用Myokit PythonExporter导出模型时遭遇错误

背景

尝试通过Myokit官方文档中的myokit.formats.python.PythonExporter将Myokit模型导出为Python文件。

第一次尝试代码

model1, protocol, x = myokit.load('dn-1985-if-gna.mmt')
sim = myokit.Simulation(model1, protocol)

exporter= myokit.formats.python.PythonExporter()
exporter.model('dn-1985-if-gna_py.mmt', model1)

第一次报错信息

NotImplementedError                       Traceback (most recent call last)
c:\More_Program_Files\Coding\Jupyter_files\2023_cellml_myokit\2023_07_04_myokit_tut.ipynb Cell 48 in ()
      1 exporter= myokit.formats.python.PythonExporter()
----> 2 a = exporter.model('dn-1985-if-gna_copy_py.mmt', sim)

File c:\More_Program_Files\Anaconda3\lib\site-packages\myokit\formats\__init__.py:61, in Exporter.model(self, path, model)
     54 def model(self, path, model):
     55     """
     56     Exports a :class:`myokit.Model`.
     57 
     58     The output will be stored in the **file** ``path``. A
     59     :class:`myokit.ExportError` will be raised if any errors occur.
     60     """
---> 61     raise NotImplementedError

NotImplementedError: 

第二次尝试代码

猜测类对象创建方式有误,改用以下写法:

exporter= myokit.formats.python.PythonExporter
exporter.model('dn-1985-if-gna_py.mmt', model1)

第二次报错信息

TypeError                                 Traceback (most recent call last)
c:\More_Program_Files\Coding\Jupyter_files\2023_cellml_myokit\2023_07_04_myokit_tut.ipynb Cell 48 in ()
      1 exporter= myokit.formats.python.PythonExporter
----> 2 exporter.model('dn-1985-if-gna_copy_py.mmt', model)

TypeError: model() missing 1 required positional argument: 'model'

补充说明

已测试多个模型,问题依旧存在。

内容的提问来源于stack exchange,提问作者Diana

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 00:52:48