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 allclose allBasic Examples (3)
Start an external Python session, automatically discovering any usable installations:
Stop the session with DeleteObject:
| In[3]:= |
Start an external Python session using the executable in /usr/local/bin/python2.7:
Sessions are persistent across calls to ExternalEvaluate:
| In[2]:= |
Stop the session with DeleteObject:
| In[4]:= |
Specifying the language only will automatically find a suitable installation, regardless of version:
Get the version automatically used:
Start a session with a specific version of the system with the "Version" key:
Code in some language versions may run, while it may fail in other versions:
| In[7]:= |
Scope (2)
See Also
ExternalEvaluate ExternalSessions ExternalSessionObject FindExternalEvaluators StartProcess Install DeleteObject