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

Allow for using the "old" source way of activating virtual environments #22289

Open
brettcannon opened this issue Oct 23, 2023 · 6 comments
Open
Labels
area-environments Features relating to handling interpreter environments community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs proposal Need to make some design decisions

Comments

@brettcannon
Copy link
Member

Via #22270 . We would probably offer a setting to let you choose "command" or "environment variables" as how we would do virtual environment activation. We could leave the "on"/"off" option as separate so that things can (potentially) work with the dedicated "Python Terminal" command.

@brettcannon brettcannon added the feature-request Request for new features or functionality label Oct 23, 2023
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 23, 2023
@brettcannon brettcannon added area-environments Features relating to handling interpreter environments needs community feedback Awaiting community feedback community ask Feature request that the community expressed interest in and removed triage-needed Needs assignment to the proper sub-team labels Oct 23, 2023
@github-actions
Copy link

Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

@brettcannon
Copy link
Member Author

Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.

We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.

@EeyoreLee
Copy link

@brettcannon - hi, does it mean the terminal will auto-activated with correct conda env without the setting conda config --set auto_activate_base False. Like auto run a command conda activate xxx when the terminal is first initialized.

@brettcannon
Copy link
Member Author

Like auto run a command conda activate xxx when the terminal is first initialized.

This feature request would bring back the old way of activating environments as an option. If you're asking about the current way via environment variables, then please open a Discussion.

@MicaelJarniac
Copy link

I need this! I've been using Zsh for Humans, and something about it just doesn't work at all with the new activation method. I think it's related to it running inside a headless tmux session, or something like that.

The old way worked perfectly for me.

Here's what's happening to me with this new method:

Boring stuff
❯ which python
/home/micael/.pyenv/shims/python
❯ which mypy
/home/micael/projects/playground/.venv/bin/mypy
❯ echo $VIRTUAL_ENVecho $PATH
/home/micael/.pyenv/shims:/home/micael/bin:/home/micael/.vscode/extensions/ms-python.python-2024.7.11281013/python_files/deactivate/zsh:/home/micael/projects/playground/.venv/bin:/home/micael/.pyenv/bin:/home/micael/.local/bin:/home/micael/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/micael/.cache/zsh4humans/v5/fzf/bin
❯ . .venv/bin/activate
❯ which python
/home/micael/projects/playground/.venv/bin/python
❯ which mypy
/home/micael/projects/playground/.venv/bin/mypy
❯ echo $VIRTUAL_ENV
/home/micael/projects/playground/.venv
❯ echo $PATH
/home/micael/projects/playground/.venv/bin:/home/micael/.pyenv/shims:/home/micael/bin:/home/micael/.vscode/extensions/ms-python.python-2024.7.11281013/python_files/deactivate/zsh:/home/micael/projects/playground/.venv/bin:/home/micael/.pyenv/bin:/home/micael/.local/bin:/home/micael/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/micael/.cache/zsh4humans/v5/fzf/bin

Notice how which python and echo $VIRTUAL_ENV change after manually activating the venv. I also don't get the venv indicator on my prompt without activating manually.

@TheFlux7
Copy link

#11039 is still labelled as "experiment"

So as a workaround, you can use the old source way of activating virtual environments by adding one of these options in your settings.json (from specific to general):

  • "python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]: it will disable this specific experiment
  • "python.experiments.enabled": false: it will disable all python experiments
  • "telemetry.telemetryLevel": "off": it will opt you out of A/B testing from VS Code and all other Microsoft extensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-environments Features relating to handling interpreter environments community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs proposal Need to make some design decisions
Projects
None yet
Development

No branches or pull requests

4 participants