- Automatically activate and deactivate python virtualenv for PowerShell users.
- When you enter into the python project's top folder with
venv,.venvor.envfolder, this script will automatically activate it. - When you go outside of the project folder, this will automatically deactivate it.
- When you enter into the python project's top folder with
-
v1.1
- Added support for automatically activating venv in an ancestor folder when jumping directly into a deep subfolder of a project from outside.
-
v1.0
- Initial Release
- Place the
virtualenv-auto-activate.ps1file anywhere you like. - Add below into the PowerShell's profile file (
$profile).- Don't miss the first
.and the white space.
- Don't miss the first
. "<ABSOLUTE_PATH_TO>\virtualenv-auto-activate.ps1"- Hint.
- The
$profilefile may be in the path below, I think. (You can know it by just typing$profilein your PowerShell)- [PS 5]
C:\Users\<USER_NAME>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 - [PS 7]
C:\Users\<USER_NAME>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
- [PS 5]
- The
- Delete
virtualenv-auto-activate.ps1file, and remove the line you write into your$profile.
- If you want to use some other name for the virtualenv folder than
venv,.venvor.env, change$VENV_NAMESdefinition in thevirtualenv-auto-activate.ps1at line3(or thereabouts).