如何列出Linux中的所有python虚拟环境?
我在Debian OS中配置了多个Python环境.有没有办法列出Linux中所有已配置的环境?
I have more than one Python environment configured in my Debian OS. Is there a way to list all configured environments in Linux?
这与下面的注释中指出的可能重复项不同.我的意思是仅使用virtualenv
创建的虚拟环境.
This is different from the possible duplicate as indicated in the comment below. I mean virtual environments created using virtualenv
only.
如果仅使用低级的virtualenv ...{directory}
来创建virtualenv,则仅在其中包含该特定环境的某个目录中.您只能通过在$HOME
目录(或您可能用于创建virtualenvs的任何其他目录列表)上运行find
来列出"这些内容,以查找python安装.希望遵循一些约定,例如将它们全部存储在~/virtualenvs
中. (另请参见在何处创建virtualenvs?)
If only using the lowly virtualenv ...{directory}
to create a virtualenv, then there is just some directory somewhere that has that specific environment in it. You can only "list" these by running find
on your $HOME
directory (or any other list of directories you might have used to create virtualenvs) looking for python installations. Hopefully some convention was followed like storing them all in ~/virtualenvs
. (See also Where should virtualenvs be created? )
如果使用virtualenvwrapper
,则如前所述,使用命令lsvirtualenv
列出使用mkvirtualenv
创建的环境.默认情况下,它们都在~/.virtualenvs
中.请参见 https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
If using virtualenvwrapper
, then as mentioned, use the command lsvirtualenv
to list envs that were created with mkvirtualenv
. They are all in ~/.virtualenvs
by default. See https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
如果使用conda
,则可以使用conda info --envs
或conda env list
列出通过conda create --name {my_env} [...]
创建的虚拟环境.请参见 https://conda.io/docs/using/envs.html#列出所有环境
If using conda
, you can list virtual envs created via conda create --name {my_env} [...]
, using either conda info --envs
or conda env list
. See https://conda.io/docs/using/envs.html#list-all-environments