OpenModelica 问题(ModelicaSystem 错误)
Problem with OpenModelica (error with ModelicaSystem)
我尝试 运行 python 脚本,但我在使用 ModelicaSystem 的地方遇到了错误,但我不明白如何解决这个问题
from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
model_path=omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
from OMPython import ModelicaSystem
mod=ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
mod.buildModel()
错误:
Traceback (most recent call last):
File "C:\Users\Aleksandr\Documents\OpenModelica\test.py", line 5, in <module>
mod=ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 720, in __init__
self.__loadingModel()
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 760, in __loadingModel
self.buildModel()
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 770, in buildModel
self.xmlparse()
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 815, in xmlparse
ch = sv.getchildren()
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'
Process finished with exit code 1
请注意,此方法自 3.2 起已弃用,但仅在 3.8 中发出警告:
访问这个 link
https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren
我尝试 运行 python 脚本,但我在使用 ModelicaSystem 的地方遇到了错误,但我不明白如何解决这个问题
from OMPython import OMCSessionZMQ
omc = OMCSessionZMQ()
model_path=omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
from OMPython import ModelicaSystem
mod=ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
mod.buildModel()
错误:
Traceback (most recent call last):
File "C:\Users\Aleksandr\Documents\OpenModelica\test.py", line 5, in <module>
mod=ModelicaSystem(model_path + "BouncingBall.mo","BouncingBall")
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 720, in __init__
self.__loadingModel()
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 760, in __loadingModel
self.buildModel()
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 770, in buildModel
self.xmlparse()
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python39\lib\site-packages\OMPython\__init__.py", line 815, in xmlparse
ch = sv.getchildren()
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'
Process finished with exit code 1
请注意,此方法自 3.2 起已弃用,但仅在 3.8 中发出警告:
访问这个 link
https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren