Wolfram Research

Function Repository Resource:

FindPythonExecutable (1.2.0) current version: 1.3.1 »

Source Notebook

Automatically attempt to find a Python executable on the current machine

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["FindPythonExecutable"][]

searches for a Python executable on the current machine and asks to install it with SystemInstall if not found.

ResourceFunction["FindPythonExecutable"][{"Python",opts}]

gets the executable corresponding to the options opts of the Python eveluator.

ResourceFunction["FindPythonExecutable"][assoc]

gets the executable specified by assoc.

ResourceFunction["FindPythonExecutable"][ExternalSessionObject[]]

gets the executable corresponding to the given Python session.

ResourceFunction["FindPythonExecutable"]["uuid"]

finds a Python executable for the external evaluator corresponding to the given UUID.

Details

In ResourceFunction["FindPythonExecutable"][assoc], elements of the association can be the same as in StartExternalSession.

Examples

Basic Examples (4) 

Find a Python executable on the current system:

In[1]:=
ResourceFunction["FindPythonExecutable"][]
Out[1]=

Get the executable corresponding to an association:

In[2]:=
ResourceFunction[
 "FindPythonExecutable"][<|"System" -> "Python", "Version" -> "3.7.0"|>]
Out[1]=

Use an ExternalSessionObject:

In[3]:=
session = StartExternalSession["Python"]
Out[3]=
In[4]:=
ResourceFunction["FindPythonExecutable"][session]
Out[4]=

Use a UUID:

In[5]:=
ResourceFunction[
 "FindPythonExecutable"]["bd9f642c-b3d6-4984-a165-18306797fdb9"]
Out[5]=

Version History

  • 1.3.1 – 01 April 2022
  • 1.3.0 – 25 February 2022
  • 1.2.0 – 18 May 2021

Related Resources

Author Notes

Changelog

1.1.0 - 2021-01-29

Fixed
Fixed an issue with python executables not being found in 12.2 due to a change in FindExternalEvaluators.
Fixed an issue with python executables not being found when using a UUID corresponding to an external evaluator.
Changed
FindPythonExecutable now returns a Failure object instead of remaining unevaluated when there's an error.
ToDo
Partial version specifications should also be accepted, cf.:
In[1]:=
FindPythonExecutable[{"Python", "Version" -> "3.8"}]
In[2]:=
StartExternalSession[{"Python", "Version" -> "3.8"}]

License Information