0

I have a local virtualenv (venv) that was activated.

My script executes another script using subprocess.call(), but that causes the new script to be executed outside of the virtualenv.

Is there any way to execute another process but keep it inside the virtualenv?

EDIT: I don't it's a duplicate of the given links since I assume it is possible to avoid reactivating the virtualenv, and can somehow "stay within it"

user972014
  • 3,296
  • 6
  • 49
  • 89
  • Possible duplicate of [Activate a virtualenv with a Python script](https://stackoverflow.com/questions/6943208/activate-a-virtualenv-with-a-python-script) – phd Aug 14 '19 at 10:22
  • https://stackoverflow.com/search?q=%5Bvirtualenv%5D+activate+subprocess – phd Aug 14 '19 at 10:22

2 Answers2

3

I found it possible to use

subprocess.call([sys.executable, "some_script.py", "--param1"])
user972014
  • 3,296
  • 6
  • 49
  • 89
0

In the bin folder of your virtualenv you can find a file named activate_this.py. You can use it to activate the virtualenv for the current interpreter. Documentation is inside the file.

jhinghaus
  • 770
  • 10
  • 27