-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Labels
Milestone
Description
Refs: #227
- macOS : @meganrogge
- linux : @joshspicer
- windows: @anthonykim1
Complexity: 3
Requirements
Install the latest pre-release of the Python Environments extension: https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-python-envs
add the following to your user settings.json and reload
"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"]
Important (before start)
✋ NOTE the following steps will change your shell startup scripts. Please take a backup of your shell startup.
Powershell:
Bash/sh:
~/.bashrc
Git bash:
windows: %USERPROFILE%/.bashrc
other: ~/.bashrc
zsh:
~/.zshrc
fish:
~/.config/fish/config.fish
Setup
- Do this external to VS Code. Setup a directory with a python file and an environment. Creating python environment can be done by running
python -m venv .venv
from the workspace directory. - Open that workspace and install the above extension. Make sure both python extension and python envs extension are activated. You should see python version in the bottom right corner if you have a python file open.
- Note: You may need to reload, if you already had python extension. (you will see 2 python versions in the bottom right corner)
Testing
- Go to settings and change this
python-envs.terminal.autoActivationType
setting toshellStartup
. - If you have, terminals open, you will see a modal asking you to update shell profiles for the open terminals.
- If you don't have any terminals open then you will not see the modal until you create a terminal
- Terminal should be activated with the environment you have selected. Already, open terminals will execute a command. Newly, opened terminals after settings and profile change should not execute a command on open.
- Opening a terminal in vscode should have the virtual environment activated. A test is to print
VRITUAL_ENV
env variable for your shell. likeecho $VIRTUAL_ENV
. Your prompt may also show.venv
. - Reloading VS Code should give you activated terminals. you should not see any modals asking you to update shell startup. This is a one time change.
- There is a command to revert all the changes:
Python Envs: Revert Shell Startup Script Changes
. running this should also switch you back to command mode in thepython-envs.terminal.autoActivationType
. - Selecting
Cancel
when the profile update modal is shown only hides it in your current VS Code session. We plan on persisting explicit Cancel. Provide Feedback on your expectation.
Known Issues: ✋
- Command Prompt: You have to restart VS Code after updating command prompt profile. We don't automatically do this in this build.
Important (Finishing TPI)
✋ NOTE: restore your profiles