Code Monkey home page Code Monkey logo

venv-wrapper's Introduction

venv-wrapper

zsh plugin defining functions to wrap working with python's builtin venv module

Managing your virtual environments using python's python -m venv has the advantage of not requiring any external dependencies (unlike virtualenv), but has the disadvantage of not being very user-friendly/fast.

This plugin provides zsh functions to ease the management of your virtual environments.

Installation

If you use zgen as your plugin manager, you can simply add zgen load glostis/venv-wrapper to the relevant section of your ~/.zshrc (see here for an example ~/.zshrc using zgen to load plugins).

Usage

To list your existing virtual environments:

$ venv
Type `venv name_of_env` to activate a virtual environment.

Here is the list of existing virtual environments:
--------------------------------------------------
my_venv_1
my_venv_2

Activating an existing virtual environment:

$ venv my_venv_1
(my_venv_1) $

Deactivating a virtual environment:

(my_venv_1) $ deactivate
$

Creating a new virtual environment:

$ venv my_venv_3
Virtual environment `my_venv_3` does not exist.
Do you want to create it? [y/n] y
Created and activated venv my_venv_3
(my_venv_3) $

(you can also directly call mkvenv my_venv_3 which will skip the prompt)

Removing a virtual environment:

(my_venv_3) $ deactivate  # You must be outside of a venv before removing it
$ rmvenv my_venv_3
Removed venv my_venv_3

This plugin autocompletes the names of existing virtual environments (try venv my_ven<TAB>)

Configuration

You can set the VENV_WRAPPER_PYTHON environment variable to choose which python executable is used to create virtual environments. By default, python3 is used.

venv-wrapper's People

Contributors

glostis avatar

Stargazers

 avatar

Watchers

 avatar  avatar

venv-wrapper's Issues

mkvenv doesn't allow me to create a venv - asks me to deactivate first

OS: macOS Mojave 10.14.6
Oh-my-zsh on iTerm

When running mkvenv, venv-wrapper returns with the message:
You must first deactivate your current virtual environment before creating a new one, by typing: 'deactivate'

I have no active venv - there is no venv to deactivate.

Looking at the script, the output of
python -c "import sys; import os; assert hasattr(sys, 'base_prefix'); print(os.path.basename(sys.prefix))" 2> /dev/null
is 3.8.2 on my system. I'm guessing this is the result of print(os.path.basename(sys.prefix).
Because it returns this, it thinks I have a venv already active...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.