Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all Pipenv environments

How do you list all Pipenv environments like virtualenv's lsvirtualenv command? The documentation does not say how. Thanks a lot to all for the help given. Cheers!

like image 740
Django102 Avatar asked Aug 18 '18 00:08

Django102


People also ask

How do you list all in Pipenv?

In Ubuntu by default, pipenv creates a folder in $HOME/. local/share/virtualenvs/ whit the name of the virtual env, then listing that folder I have a list of all my environments. To make life easier, I have created an alias to perform this operation.

Where are Pipenv environments stored?

pipenv stores the packages inside your local machines shared directory called virtualenvs (~/. local/share/virtualenvs/<env-name> ). It ensures that you don't need to use pip and virtualenv separately.

What is a Pipenv environment?

Pipenv is a tool that provides all necessary means to create a virtual environment for your Python project. It automatically manages project packages through the Pipfile file as you install or uninstall packages. Pipenv also generates the Pipfile.

How do you get into the Pipenv environment?

To activate the environment, just navigate to your project directory and use pipenv shell to launch a new shell session or use pipenv run <command> to run a command directly.


3 Answers

Why not simply looking for existing virtual environments? To check where they are stored you can activate one virtual env and get its path:

$pipenv shell
$pipenv --venv
 > /path/to/existing_venvs/current_venv
ls /path/to/existing_venvs/
 > cython-pr4GGvfQ/  openCV-f4drK-E5/

I don't know if pipenv can store venvs in other places, but at least for me this is enough to know how many and which venvs I have.

like image 125
smajtkst Avatar answered Sep 18 '22 14:09

smajtkst


You can add the following alias to .bash_aliases:

alias pipenv-list='for venv in ~/.local/share/virtualenvs/* ; do basename $venv; cat $venv/.project | sed "s/\(.*\)/\t\1\n/" ; done'

This will list all the virtual environments and the corresponding project (source) folder like:

$ pipenv-list
<PIPENV>
    <PROJECT_HOME_DIR>
[...]
like image 29
Martin Thøgersen Avatar answered Sep 19 '22 14:09

Martin Thøgersen


As AChampion said, pipenv has no lsvirtualenv or similar functions.

The creator of pipenv, Kenneth Reitz, told here that is not planned to implement anything of the sort, and that people should rely in other tools like pew.

I've tried pew and pipes and both are good tools, but not the exact tools I was looking for my workflow, so for my personal use I built pipenvwrapper using the base code of virtualenvwrapper.

Some of the supported functions of pipenvwrapper are: workon, lsvirtualenv, cdproject, cdvirtualenv, cdsitepackages, mkproject and rmvirtualenv.

Check if any of those 3 tools fit your needs.

like image 30
Peibolvig Avatar answered Sep 18 '22 14:09

Peibolvig