Subprocess crashes unexpectedly from PyDev, works

2019-09-11 03:36发布

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条回答
三岁会撩人
2楼-- · 2019-09-11 04:13

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.

查看更多
登录 后发表回答