如何列出 Linux 中的所有 python 虚拟环境? [英] How to list all python virtual environments in Linux?

查看:94
本文介绍了如何列出 Linux 中的所有 python 虚拟环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Debian 操作系统中配置了多个 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 中.(另请参阅应该在哪里创建虚拟环境?)

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 创建的 env.默认情况下,它们都在 ~/.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 create --name {my_env} [...] 创建的虚拟环境,使用 conda info --envsconda 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

这篇关于如何列出 Linux 中的所有 python 虚拟环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆