Subprocess crashes unexpectedly from PyDev, works fine from double click in windows explorer

百般思念 提交于 2020-01-16 18:09:49

问题


I've spent quite a bit of time trying to figure this out. I'm trying to invoke this line to run abaqus (an FEA program):

popen = subprocess.Popen(callCommand, cwd=workDir, creationflags=subprocess.CREATE_NEW_CONSOLE)
popen.wait()

When double clicking on the .py file everthing works fine. However on running it from Eclipse, Abaqus crashes:

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Then later I also get "SMAPython.exe has stopped working".

I've played around with admin privilege settings but to no avail. Don't have the rep to tag it with Abaqus.


回答1:


The solution (which I've come accross after writting a draft for the question) was found here:

http://sourceforge.net/p/pydev/discussion/293649/thread/94a76ecb/

Basically, PyDev adds some environment variables that don't play well with Abaqus, so to turn them off the following code can be used:

import os
try:
    os.environ.pop('PYTHONIOENCODING')
except KeyError:
    pass
# now call abaqus...

Hopefully this is of use to someone, I've spent almost two days fixing this. It is a bit of a niche use of PyDev (I'm not a programmer, I'm a Civil Engineer) but I think it is much more powerful to have Eclipse take care of all the source files. Abaqus CAE files are all binary and proprietary so source control and custom edits are a pain otherwise.

I guess in any case the solution is to trace the problem by taking bits of it off and checking what works and what the differences are.



来源:https://stackoverflow.com/questions/17982483/subprocess-crashes-unexpectedly-from-pydev-works-fine-from-double-click-in-wind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!