How to use 'conda list environments' in Python

Every line of 'conda list environments' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
9def conda_env_exists(name):
10 r"""Determine if a conda environment already exists.
11
12 Args:
13 name (str): Name of the environment to check.
14
15 Returns:
16 bool: True the the environment exits, False otherwise.
17
18 """
19 args = ['conda', 'info', '--envs']
20 out = call_conda_command(args)
21 envs = []
22 for x in out.splitlines():
23 if x.startswith('#') or (not x):
24 continue
25 envs.append(x.split()[0])
26 return (name in envs)
13def handle(self):
14 from poetry.utils.env import EnvManager
15
16 manager = EnvManager(self.poetry)
17 current_env = manager.get()
18
19 for venv in manager.list():
20 name = venv.path.name
21 if self.option("full-path"):
22 name = str(venv.path)
23
24 if venv == current_env:
25 self.line("{} (Activated)".format(name))
26
27 continue
28
29 self.line(name)

Related snippets