Subprocess call in Python interpreter results in memory corruption

Probably you can simply launch your process using custom environment. We do this when we launch Elastix. Example:

  1. Create custom environment
  2. Launch process using subprocess.Popen

Note that in case of Elastix, we added more directories to the path/LD path. In your case you probably want to either add your external program’s paths to the beginning of relevant environment variables; or remove all Slicer-specific paths from environment variables.