StartExternalSession
✖
StartExternalSession
Listing of External Evaluators »

starts an external session using the external evaluator sys, returning an external session object.
specifies that output from the external evaluator should be converted to the specified type.
uses the database specified by ref to start a database session.
Details



- StartExternalSession starts an external process that can be used to implement an external evaluator session in which there are multiple evaluations requested by ExternalEvaluate.
- In StartExternalSession[assoc], elements of the association can include:
-
"System" the external system or language to start "Evaluator" the specific evaluator to execute code "Name" the registered name of an evaluator "ID" a unique identifier "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 "Julia" Julia "Ruby" Ruby "R" R "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", are dependent on the evaluation system, and typically include:
-
"Expression" attempt to convert to a Wolfram Language expression "String" give the raw string output by the external evaluator - The possible settings for evaluator in StartExternalSession[{sys,"Evaluator"evaluator},…] 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".
- StartExternalSession[{"sys",opts}] is equivalent to StartExternalSession[<"System""sys",opts >].
- StartExternalSession[{sys,"ID""id",…}] either returns an already running session with the given "id" or starts a new session with the unique "id".
- 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.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Start an external Python session, automatically discovering any usable installations:

https://wolfram.com/xid/0k7vpfug13i7m-lketrq


https://wolfram.com/xid/0k7vpfug13i7m-m3pl17

Stop the session with DeleteObject:

https://wolfram.com/xid/0k7vpfug13i7m-0rmxua
Start a session using Python Version 3:

https://wolfram.com/xid/0k7vpfug13i7m-cvhjs4


https://wolfram.com/xid/0k7vpfug13i7m-gbxbwc


https://wolfram.com/xid/0k7vpfug13i7m-oh8s2q
Start a new Python session in a provisioned environment:

https://wolfram.com/xid/0k7vpfug13i7m-j80han


https://wolfram.com/xid/0k7vpfug13i7m-jdl2g4

Scope (16)Survey of the scope of standard use cases
Basic Uses (2)
Multiple external sessions can be run simultaneously:

https://wolfram.com/xid/0k7vpfug13i7m-oyl4nd


https://wolfram.com/xid/0k7vpfug13i7m-3vzav6
Start an external Python session using the executable in /usr/bin/python3:

https://wolfram.com/xid/0k7vpfug13i7m-e4v0la

Use the session for multiple calls to ExternalEvaluate:

https://wolfram.com/xid/0k7vpfug13i7m-6wq5wr

https://wolfram.com/xid/0k7vpfug13i7m-jvghn7

Stop the session with DeleteObject:

https://wolfram.com/xid/0k7vpfug13i7m-g6r2hg
Session Options (14)
"ReturnType" (4)
For most systems, the default return type is "Expression":

https://wolfram.com/xid/0k7vpfug13i7m-wtbdnk


https://wolfram.com/xid/0k7vpfug13i7m-o6pe7m


https://wolfram.com/xid/0k7vpfug13i7m-v6kqn2


https://wolfram.com/xid/0k7vpfug13i7m-1rxkyc
Numbers, strings, lists and associations are automatically imported for the "Expression" return type:

https://wolfram.com/xid/0k7vpfug13i7m-4bqtee


https://wolfram.com/xid/0k7vpfug13i7m-5qg8yf


https://wolfram.com/xid/0k7vpfug13i7m-7plv6t


https://wolfram.com/xid/0k7vpfug13i7m-gw121v
The return type of "String" returns a string of the result in the external language:

https://wolfram.com/xid/0k7vpfug13i7m-blcv4


https://wolfram.com/xid/0k7vpfug13i7m-d3mosj


https://wolfram.com/xid/0k7vpfug13i7m-7m4kl8


https://wolfram.com/xid/0k7vpfug13i7m-vmx606
When using a database, the default return type is "Dataset":

https://wolfram.com/xid/0k7vpfug13i7m-xsyvsz

https://wolfram.com/xid/0k7vpfug13i7m-4ns3rj


https://wolfram.com/xid/0k7vpfug13i7m-bqup95

"ReturnType" can be used to return data in a different form:

https://wolfram.com/xid/0k7vpfug13i7m-7459fm

https://wolfram.com/xid/0k7vpfug13i7m-g5j12f


https://wolfram.com/xid/0k7vpfug13i7m-cgvwh6

https://wolfram.com/xid/0k7vpfug13i7m-6oe2ed


https://wolfram.com/xid/0k7vpfug13i7m-ppsurx

https://wolfram.com/xid/0k7vpfug13i7m-5rzuvf


https://wolfram.com/xid/0k7vpfug13i7m-c8853f

https://wolfram.com/xid/0k7vpfug13i7m-0o9wgp


https://wolfram.com/xid/0k7vpfug13i7m-e4wcwr
"Evaluator" (3)
Evaluate code using a specified "Evaluator":

https://wolfram.com/xid/0k7vpfug13i7m-l8qzu4


https://wolfram.com/xid/0k7vpfug13i7m-eafuyy


https://wolfram.com/xid/0k7vpfug13i7m-rm9a1x
An Association can be used to start a Python provisioned environment:

https://wolfram.com/xid/0k7vpfug13i7m-jqhheo

Use the session to evaluate the code:

https://wolfram.com/xid/0k7vpfug13i7m-j25eq

https://wolfram.com/xid/0k7vpfug13i7m-q9c0ta

https://wolfram.com/xid/0k7vpfug13i7m-5vb73
When using a File with the "SQL" evaluator, the target can be a path to an SQLite file or a DatabaseReference specification:

https://wolfram.com/xid/0k7vpfug13i7m-gp06yk

https://wolfram.com/xid/0k7vpfug13i7m-vnifkx


https://wolfram.com/xid/0k7vpfug13i7m-gj1i7c

https://wolfram.com/xid/0k7vpfug13i7m-xbwrlg


https://wolfram.com/xid/0k7vpfug13i7m-0lzjia
"Name" (1)
Register an evaluator using a name:

https://wolfram.com/xid/0k7vpfug13i7m-7fgail

Start a session using the registered evaluator by referring to it by name:

https://wolfram.com/xid/0k7vpfug13i7m-2j03ng


https://wolfram.com/xid/0k7vpfug13i7m-rp923e


https://wolfram.com/xid/0k7vpfug13i7m-b0muyh
"ID" (1)
Start an evaluator with a given "ID":

https://wolfram.com/xid/0k7vpfug13i7m-22lijw

The operation is idempotent; starting a session with the same "ID" will return the same running session:

https://wolfram.com/xid/0k7vpfug13i7m-g83gz9

You can check that there is only one running session, even if you run StartExternalSession two times:

https://wolfram.com/xid/0k7vpfug13i7m-h5bap1


https://wolfram.com/xid/0k7vpfug13i7m-13g1pr
"SessionProlog" (2)
Use "SessionProlog" to perform a side effect at the start of a session:

https://wolfram.com/xid/0k7vpfug13i7m-3lqh5y

https://wolfram.com/xid/0k7vpfug13i7m-g6q0rr


https://wolfram.com/xid/0k7vpfug13i7m-dxyfy3
Start an external session and import a library at the beginning of the session:

https://wolfram.com/xid/0k7vpfug13i7m-wzkokn

Evaluate a function from the imported library:

https://wolfram.com/xid/0k7vpfug13i7m-m5fo6c


https://wolfram.com/xid/0k7vpfug13i7m-lf43oa
"SessionEpilog" (1)
"Prolog" (1)
Properties & Relations (4)Properties of the function, and connections to other functions
Each session runs in its own process:

https://wolfram.com/xid/0k7vpfug13i7m-rx95mp

The process IDs for each session are different:

https://wolfram.com/xid/0k7vpfug13i7m-xu7nfv


https://wolfram.com/xid/0k7vpfug13i7m-x1igta
If only the language is specified, the first evaluator returned by FindExternalEvaluators is used:

https://wolfram.com/xid/0k7vpfug13i7m-x5zduw

https://wolfram.com/xid/0k7vpfug13i7m-qnuhi0


https://wolfram.com/xid/0k7vpfug13i7m-cebyxe

https://wolfram.com/xid/0k7vpfug13i7m-gw71y4


https://wolfram.com/xid/0k7vpfug13i7m-pcce2y


https://wolfram.com/xid/0k7vpfug13i7m-me9icm


https://wolfram.com/xid/0k7vpfug13i7m-gzoero
External language cells implicitly call StartExternalSession:

https://wolfram.com/xid/0k7vpfug13i7m-igr15a

A new session has been started:

https://wolfram.com/xid/0k7vpfug13i7m-r6exto

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

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

https://wolfram.com/xid/0k7vpfug13i7m-uq1fg7
Wolfram Research (2017), StartExternalSession, Wolfram Language function, https://reference.wolfram.com/language/ref/StartExternalSession.html (updated 2024).
Text
Wolfram Research (2017), StartExternalSession, Wolfram Language function, https://reference.wolfram.com/language/ref/StartExternalSession.html (updated 2024).
Wolfram Research (2017), StartExternalSession, Wolfram Language function, https://reference.wolfram.com/language/ref/StartExternalSession.html (updated 2024).
CMS
Wolfram Language. 2017. "StartExternalSession." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/StartExternalSession.html.
Wolfram Language. 2017. "StartExternalSession." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/StartExternalSession.html.
APA
Wolfram Language. (2017). StartExternalSession. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StartExternalSession.html
Wolfram Language. (2017). StartExternalSession. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StartExternalSession.html
BibTeX
@misc{reference.wolfram_2025_startexternalsession, author="Wolfram Research", title="{StartExternalSession}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/StartExternalSession.html}", note=[Accessed: 25-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_startexternalsession, organization={Wolfram Research}, title={StartExternalSession}, year={2024}, url={https://reference.wolfram.com/language/ref/StartExternalSession.html}, note=[Accessed: 25-March-2025
]}