# Subprocess call in Python interpreter results in memory corruption

**URL:** <https://discourse.slicer.org/t/subprocess-call-in-python-interpreter-results-in-memory-corruption/919>\
**Category:** Support\
**Tags:** python\
**Created:** [August 22, 2017, 1:03pm UTC](https://discourse.slicer.org/t/subprocess-call-in-python-interpreter-results-in-memory-corruption/919 "2017-08-22T13:03:10Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 3, 2017, 11:36pm UTC](https://discourse.slicer.org/t/subprocess-call-in-python-interpreter-results-in-memory-corruption/919/8 "2017-09-03T23:36:43Z")

</div>

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

1. [Create custom environment](https://github.com/lassoan/SlicerElastix/blob/777c5259eaa5eb45d46b97ce83c67f865096ec55/Elastix/Elastix.py#L423-L434)
2. [Launch process using subprocess.Popen](https://github.com/lassoan/SlicerElastix/blob/777c5259eaa5eb45d46b97ce83c67f865096ec55/Elastix/Elastix.py#L460-L466)

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.

---

_[View the full topic](https://discourse.slicer.org/t/subprocess-call-in-python-interpreter-results-in-memory-corruption/919)._
