Skip to content
Snippets Groups Projects
Commit 0651e9fe authored by John Douglas Veitch's avatar John Douglas Veitch
Browse files

Merge branch 'conda_check' into 'master'

Add logic in case conda call doesn't work

See merge request !1197
parents 0ebc4ae9 c3073eae
No related branches found
No related tags found
1 merge request!1197Add logic in case conda call doesn't work
Pipeline #490006 failed
......@@ -99,16 +99,21 @@ def env_package_list(as_dataframe=False):
# if a conda-meta directory exists, this is a conda environment, so
# use conda to print the package list
if (Path(prefix) / "conda-meta").is_dir():
pkgs = json.loads(subprocess.check_output([
"conda",
"list",
"--prefix", prefix,
"--json"
]))
conda_detected = (Path(prefix) / "conda-meta").is_dir()
if conda_detected:
try:
pkgs = json.loads(subprocess.check_output([
"conda",
"list",
"--prefix", prefix,
"--json"
]))
except (FileNotFoundError, subprocess.CalledProcessError):
# When a conda env is in use but conda is unavailable
conda_detected = False
# otherwise try and use Pip
else:
if not conda_detected:
try:
import pip # noqa: F401
except ModuleNotFoundError: # no pip?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment