Skip to content

Instantly share code, notes, and snippets.

@tjguk
Created November 7, 2019 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjguk/40b05d35bbce0a8ef34cd4bb32e545b7 to your computer and use it in GitHub Desktop.
Save tjguk/40b05d35bbce0a8ef34cd4bb32e545b7 to your computer and use it in GitHub Desktop.
Removing PYTHONPATH from environment
import os, sys
import subprocess
## env = {}
## env['SystemRoot'] = os.environ['SystemRoot']
env = dict(os.environ)
del env['PYTHONPATH']
print(subprocess.run(["c:/temp/mu/yyy/scripts/python.exe", "-c", 'import sys; print(sys.path)'], stdout=subprocess.PIPE, env=env).stdout)
print(subprocess.run(["c:/temp/mu/yyy/scripts/python.exe", "-m", "pip", "freeze"], stdout=subprocess.PIPE, env=env).stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment