MCPcopy Create free account
hub / github.com/ipython/ipython / _get_conda_executable

Function _get_conda_executable

IPython/core/magics/packaging.py:26–44  ·  view source on GitHub ↗

Find the path to the conda executable

()

Source from the content-addressed store, hash-verified

24
25
26def _get_conda_executable():
27 """Find the path to the conda executable"""
28 # Check if there is a conda executable in the same directory as the Python executable.
29 # This is the case within conda's root environment.
30 conda = os.path.join(os.path.dirname(sys.executable), 'conda')
31 if os.path.isfile(conda):
32 return conda
33
34 # Otherwise, attempt to extract the executable from conda history.
35 # This applies in any conda environment.
36 R = re.compile(r"^#\s*cmd:\s*(?P<command>.*conda)\s[create|install]")
37 with open(os.path.join(sys.prefix, 'conda-meta', 'history')) as f:
38 for line in f:
39 match = R.match(line)
40 if match:
41 return match.groupdict()['command']
42
43 # Fallback: assume conda is available on the system path.
44 return "conda"
45
46
47CONDA_COMMANDS_REQUIRING_PREFIX = {

Callers 1

condaMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected