Start Python

Python runs in an external session that must be started before you can evaluate Python code:

Optionally load a Python file

Here is an example Python file with a function that prints a message in uppercase:

Load the file into the current external session:

Use the functions

Call Python functions with ExternalEvaluate. There are three ways to do this.

Use an association of named Python command-line elements:

Give Python code directly as a string:

Use a shorthand notation, with Python functions and arguments connected with arrows:

Terminate the session

Stop the external Python session:

Notes

StartExternalSession is not supported in the Wolfram Cloud.