StartExternalSession

StartExternalSession["sys"]

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

StartExternalSession[{"sys",opts}]

uses the options opts for the external evaluator.

StartExternalSession[assoc]

starts the external evaluator specified by assoc.

StartExternalSession[systype]

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

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.
  • 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"the version of the external system
    "Executable"the name of the executable to run to start scripts with
    "ReturnType"type of object to return ("String", "Expression", ...)
    "Prolog"code to run before commands evaluated with this session
    "Epilog"code to run after commands evaluated with this 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
  • 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 all close all

Basic Examples  (2)

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

In[1]:=
Click for copyable input
Out[1]=

Evaluate code in the session:

In[2]:=
Click for copyable input
Out[2]=

Stop the session with DeleteObject:

In[3]:=
Click for copyable input

Start a session using Python Version 3:

In[1]:=
Click for copyable input
Out[1]=

Verify the version:

In[2]:=
Click for copyable input
Out[2]=

End the session:

In[3]:=
Click for copyable input

Scope  (4)

Properties & Relations  (3)

Introduced in 2017
(11.2)