COM_ERROR:((-2147352567,' extescion',(10,AspenModeler
当我在Python中使用 Aspen 自定义模型时,会发生此错误。 这是代码:
Application = win32.Dispatch('ACM Application 3700')
ACMP = Application.OpenDocument(os.path.abspath("Distillationcolumn.acmf"))
错误是
com_error: (-2147352567, 'Exception occured',
(10, 'AspenModeler', 'A string value was expected', None, 0, 0), None)
有人知道发生了什么吗?谢谢。
When I use aspen custom modeller in python, This error occurs.
Here is the code:
Application = win32.Dispatch('ACM Application 3700')
ACMP = Application.OpenDocument(os.path.abspath("Distillationcolumn.acmf"))
and the error is
com_error: (-2147352567, 'Exception occured',
(10, 'AspenModeler', 'A string value was expected', None, 0, 0), None)
Does anyone know what happened? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为我可能会提供帮助。弄清楚这个问题是我的博士学位论文的一部分,它是数字出版的Open-access-for-All在这里。请随时查看 - 解决问题的解决方案在第124页的Paper V中找到。提供解决方案的摘录如下(请注意,Pymoc是我提供的昵称,我给了我开发的软件来处理Aspen Module Co-通过Python进行的模拟):
“使用APD和PYMOC在共拟合过程中节省用户时间和精力的一个重要方面是使算法自动加载模块的能力
用户提供了其中的文件路径。但是,Win32COM包
Python 2.7默认情况下不能这样做,因为在该软件包的错误处理系统中必须被认为是错误。因此,用户需要在第一次使用适当的pymoc之前对Win32COM软件包的代码进行一次修改。
在初始化过程中,PYMOC将调用Aspen Plus Dynamics COM对象的Opentocument函数。除非已修改Win32COM(通过撰写时间后或本地用户发布后发布的版本),这将引发错误,并向用户提供错误代码。为了使PYMOC自动加载模块,此错误代码需要包含在Win32COM客户端安装文件夹中的文件dynamic.py中的“不良上下文”错误列表中。默认情况下,安装文件夹命名为:“ c:/users/[username]/anaconda2/pkgs/pywin32- [...]/lib/site-packages/win32com/client”(向python提供anaconda 2.7用作软件套件)。文件动态。应通过将错误代码添加到名为errors_bad_context的列表中,从第38行开始。
模块文件的自动加载将按预期运行,并节省大量时间
对于用户。“
希望这会有所帮助 - 祝您好运!
I think I might be able to help. Figuring out this issue was part of my PhD thesis, which is digitally published open-access-for-all here. Please feel free to have a look - the solution to your issue is found in Paper V on page 124. The excerpt providing the solution is as follows (Please note that PyMoC is the nickname I gave the software I developed to handle Aspen module co-simulations through Python):
"An important aspect of saving the user time and effort during co-simulation using APD and PyMoC is the ability to have the algorithm automatically load the modules
of which file paths have been provided by the user. However, the win32com package of
Python 2.7 cannot do this by default, due to what must be considered a bug in the error handling system of said package. As such, the user needs to perform one modification to the code of the win32com package before using properly PyMoC the first time.
During initialization, PyMoC will invoke the OpenDocument function of the Aspen Plus Dynamics COM object that the algorithm has established. Unless win32com has been modified (either by versions released after the time of writing, or by a local user), this will throw an error, and provide an error code to the user. In order to have PyMoC automatically load the modules, this error code needs to be included in the list of ‘bad context’ errors in the file dynamic.py found in the win32com client installation folder. The installation folder is by default named something to the effect of: “C:/Users/[USERNAME]/Anaconda2/pkgs/pywin32-[...]/Lib/site-packages/win32com/client” (provided Anaconda with Python 2.7 is used as a software suite). The file dynamic. py should be modified by adding the error code to the list called ERRORS_BAD_CONTEXT, beginning on row 38. Following this modification, the
automated loading of module files will function as intended, and will save lots of time
for the user."
Hope this helps -- best of luck to you!