Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot change environment in subprocess #414

Open
mbway opened this issue Dec 14, 2021 · 0 comments
Open

cannot change environment in subprocess #414

mbway opened this issue Dec 14, 2021 · 0 comments

Comments

@mbway
Copy link

mbway commented Dec 14, 2021

Activating a virtual environment from inside a python script running in another virtual environment fails.
For example I have a 'script runner' application which has a set of scripts and their associated environments.

Here is a minimal example of the problem:

import subprocess
subprocess.run(['bash', '-c', 'source activate myenv && python -c "import sys;print(sys.executable)"'])

output:

$ /usr/bin/python runner.py  # running using an interpreter not managed by pyenv
pyenv-virtualenv: activate myenv
/home/matthew/.pyenv/versions/myenv/bin/python

$ python runner.py  # running from a pyenv environment
/home/matthew/.pyenv/versions/3.9.9/envs/otherenv/bin/python  # environment did not switch

Details

  • Ubuntu 20.04
  • x86_64
  • pyenv --version == 2.2.2
  • pyenv virtualenv --version == pyenv-virtualenv 1.1.5 (python -m venv)
  • python --version == Python 3.9.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant