pyenv-win / pyenv-win-venv

A CLI to manage virtual envs with pyenv-win
Apache License 2.0
78 stars 8 forks source link

pyenv-win-venv

ko-fi

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

Installation

Dependencies

This script depends on the pyenv-win so it needs to be installed system to run this script.

Power Shell

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

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.

Add System Settings

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")

Update

Automatically using pyenv-venv update self (Recommended)

Git (If the CLI was installed using Git)

Using git pull:

Go to %USERPROFILE%\.pyenv-win-venv (which is your installed path) and run git pull

Power Shell (If the CLI was installed using the PowerScript Installation 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"

Uninstallation

CLI

pyenv-venv uninstall self

Power Shell

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

Usage

> 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.

Example

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
pyenv-venv local env_name
pyenv-venv config
pyenv-venv update self
pyenv-venv which <exec_name>
pyenv-venv help install

Note

Env automatic activation using .python-version file

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