starts an external session using the external evaluator sys, returning an external session object.


uses the options opts for the external evaluator.


uses the database specified by ref to start a database session.


starts the external evaluator specified by assoc.


specifies that output from the external evaluator should be converted to the specified type.


  • StartExternalSession starts an external process that can be used to implement an external evaluator session in which there are multiple evaluations requested by ExternalEvaluate.
  • To be usable with ExternalEvaluate, language installations must have a standard 0MQ library installed for that particular language, as well as a "JSON" library.
  • In StartExternalSession[assoc], elements of the association can include:
  • "System"the external system or language to start
    "Version"version of the external system to use (e.g. "3.6")
    "Kernel"the Jupyter kernel name (e.g. "IFSharp")
    "Target"the target to use for evaluating code
    "ReturnType"type of object to return ("String", "Expression", ...)
    "Prolog"code to run before the command
    "Epilog"code to run after the command
    "SessionProlog"code to run before the session
    "SessionEpilog"code to run after the session
  • "System" is the only required key; all others are optional.
  • In StartExternalSession[sys], possible choices of sys include:
  • "Python"Python
    "NodeJS"JavaScript running through Node.js
    "Shell"Bash, Sh, Zsh, ...
    "Jupyter"Jupyter kernel
    "SQL"SQL database
    "SQL-JDBC"SQL database using JDBC
  • Possible settings for "type" in StartExternalSession[sys"type",], or for "ReturnType", include:
  • "Expression"attempt to convert to a Wolfram Language expression
    "String"give the raw string output by the external evaluator
  • The possible settings for target in StartExternalSession[{sys,"Target"target},] depend on sys, and include:
  • "path"path to a language executable
    DatabaseReference[]an SQL database connection
    SQLConnection[]an SQL-JDBC database connection
  • Typically, StartExternalSession uses the setting "ReturnType""Expression".
  • FindExternalEvaluators gives a dataset of evaluator systems that can be used.
  • ExternalSessions gives a list of active external sessions.
  • DeleteObject[ExternalSessionObject[]] kills and removes an external session started by StartExternalSession.


open allclose all

Basic Examples  (2)

Start an external Python session, automatically discovering any usable installations:

Evaluate code in the session:

Stop the session with DeleteObject:

Start a session using Python Version 3:

Verify the version:

End the session:

Scope  (4)

Multiple external sessions can be run simultaneously:

Delete the session objects:

Start an external Python session using the executable in /usr/bin/python2.7:

Use the session for multiple calls to ExternalEvaluate:

Stop the session with DeleteObject:

Start an external session and import a library at the beginning of the session:

Evaluate a function from the imported library:

Delete the session object:

Start a session that imports a library and sets x to 0, then increments x each ExternalEvaluate call:

Define a command to compute the Factorial of x in the session:

Evaluate the command 10 times:

Verify that the result is the first 10 Factorial values:

Delete the session object:

Properties & Relations  (4)

Each session runs in its own process:

The process IDs for each session are different:

Delete the session objects:

If only the language is specified, the first evaluator returned by FindExternalEvaluators is used:

Stop the session:

Start a database session:

Run a query:

Manually close the session:

External language cells implicitly call StartExternalSession:


A new session has been started:

By default, all cells of a given system use that session:


End the session so that subsequent evaluations start in a new session:

Wolfram Research (2017), StartExternalSession, Wolfram Language function, (updated 2020).


Wolfram Research (2017), StartExternalSession, Wolfram Language function, (updated 2020).


Wolfram Language. 2017. "StartExternalSession." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020.


Wolfram Language. (2017). StartExternalSession. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2022_startexternalsession, author="Wolfram Research", title="{StartExternalSession}", year="2020", howpublished="\url{}", note=[Accessed: 03-December-2022 ]}


@online{reference.wolfram_2022_startexternalsession, organization={Wolfram Research}, title={StartExternalSession}, year={2020}, url={}, note=[Accessed: 03-December-2022 ]}