Question: This could be a silly question. I have code that calls a subprocess in Python. For it to work and find the program I will need to set an environment variable on my Mac TEST\_\_LIB\_PATH. 

```
subprocess.call(["find_info",
                          image,
                          json_file])

```

Is there a way in Python I can just import this environment variable to use instead of having to set this up globally?

Answer: 
`call` takes a keyword argument `env` that takes a mapping to use as the environment for the command. The current environment is in `os.environ`; you can extend that with something like

```
subprocess.call(["find_info", image, json_file],
                env=dict(TEST__LIB_PATH="/path/requried/for/test", 
                         **os.environ))

```
You can access environment variables with `os.environ`:

```
import os
print(os.environ['TEST__LIB_PATH'])

```

`os.environ` also has a `get()` method:

```
os.environ.get('TEST__LIB_PATH')

```

*Edit*: here's a link to [the docs](https://docs.python.org/2/library/os.html#os.environ)