Start Python
Python runs in an external session that must be started before you can evaluate Python code:
![](Files/ExecuteAPythonFileWithExternalEvaluate.en/1.png)
- If StartExternalSession returns an error, refer to the workflow Configure Python for External Evaluate.
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:
![](Files/ExecuteAPythonFileWithExternalEvaluate.en/2.png)
Use the functions
Call Python functions with ExternalEvaluate. There are three ways to do this.
Use an association of named Python command-line elements:
![](Files/ExecuteAPythonFileWithExternalEvaluate.en/3.png)
Give Python code directly as a string:
![](Files/ExecuteAPythonFileWithExternalEvaluate.en/4.png)
Use a shorthand notation, with Python functions and arguments connected with arrows:
![](Files/ExecuteAPythonFileWithExternalEvaluate.en/5.png)
Terminate the session
Stop the external Python session:
Notes
StartExternalSession is not supported in the Wolfram Cloud.