79458025

Date: 2025-02-21 16:23:33
Score: 0.5
Natty:
Report link

An improvement on @Oswin's solution. This works for me. Replace conda list with your own command after testing.

import sys
import subprocess
executable = sys.executable
conda_init_shell = '/'.join([*executable.split('/')[:-4], 'etc/profile.d/conda.sh'])
conda_init_shell
cmd = f'. {conda_init_shell} && conda activate YOUR-ENVIORONMENT-HERE && conda list'
subprocess.run(cmd, shell=True)
Reasons:
  • Whitelisted phrase (-1): works for me
  • Has code block (-0.5):
  • User mentioned (1): @Oswin's
  • Low reputation (1):
Posted by: Martin David Grunnill