A CLI to manage virtual envs with pyenv-win
To report issues for the CLI, open an issue at https://github.com/pyenv-win/pyenv-win-venv/issues
This script depends on the pyenv-win so it needs to be installed system to run this script.
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win-venv/main/bin/install-pyenv-win-venv.ps1" -OutFile "$HOME\install-pyenv-win-venv.ps1";
&"$HOME\install-pyenv-win-venv.ps1"
Note: Skip the Add System Settings Section
git clone https://github.com/pyenv-win/pyenv-win-venv "$HOME\.pyenv-win-venv"
You need to add the \bin
path to your environment variables using the following steps.
Adding the following paths to your USER PATH variable in order to access the pyenv-win-venv command
[System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv-win-venv\bin;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")
Automatically using pyenv-venv update self
(Recommended)
Using git pull
:
Go to %USERPROFILE%\.pyenv-win-venv
(which is your installed path) and run git pull
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win-venv/main/bin/install-pyenv-win-venv.ps1" -OutFile "$HOME\install-pyenv-win-venv.ps1"; &"$HOME\install-pyenv-win-venv.ps1"
pyenv-venv uninstall self
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win-venv/main/bin/install-pyenv-win-venv.ps1" -OutFile "$HOME\install-pyenv-win-venv.ps1";
&"$HOME\install-pyenv-win-venv.ps1" -Uninstall
> pyenv-win-venv
pyenv-win-venv v0.6
Copyright (c) Arbaaz Laskar <arzkar.dev@gmail.com>
Usage: pyenv-win-venv <command> <args>
A CLI to manage virtual envs with pyenv-win
Commands:
init search for .python-version file in the
current directory and activate the env
activate activate an env
deactivate deactivate an env
install install an env
uninstall uninstall an env
uninstall self uninstall the CLI and its envs
list <command> list all installed envs/python versions
local set the given env in .python-version file
config show the app directory
update self update the CLI to the latest version
which <command> show the full path to an executable
help <command> show the CLI/<command> menu
Flags:
debug To show debug log
Note: pyenv-venv
is an alias for pyenv-win-venv
so either one can be used to call the CLI.
pyenv install 3.8.5
)pyenv-venv install 3.8.5 env_name
pyenv-venv uninstall env_name
pyenv-venv activate env_name
pyenv-venv deactivate
pyenv-venv list envs
pyenv-venv list python
.python-version
filepyenv-venv local env_name
pyenv-venv config
pyenv-venv update self
pyenv-venv which <exec_name>
pyenv-venv help install
.python-version
fileYou can set the env for a directory using a .python-version
file and the CLI can automatically activate the env if a shell is
opened in that directory.
.python-version
file: It should only contain the name of the env and can be created by manually or by using the command: pyenv-venv local env_name
You can manually activate the env if the directory has a .python-version
file by calling pyenv-venv init
To enable the automatic feature, you need to add pyenv-venv init
to your the PowerShell Profile.
Steps to do this:
Test-Path $profile
If its False
, then you need to create a new profile.
New-Item -path $profile -type file –force
The location to the profile will be shown on the shell.
profile.ps1
file and append the following line.pyenv-venv init
Save and restart the shell.
Note: If you want the CLI to search for a .python-version
file by traversing from the current working directory to the root till it finds the file, use pyenv-venv init root