-
See Also
- ExternalEvaluate
- ExternalObject
- ExternalOperation
- StartExternalSession
- APIFunction
- FunctionCompile
- CloudFunction
- Function
-
- Formats
- JavaScriptExpression
- PythonExpression
-
- External Evaluation Systems
- Python
- NodeJS
- Julia
- Java
- Octave
- Shell
- Ruby
- R
- Jupyter
- SQL
- SQL-JDBC
- Related Guides
- Workflows
-
-
See Also
- ExternalEvaluate
- ExternalObject
- ExternalOperation
- StartExternalSession
- APIFunction
- FunctionCompile
- CloudFunction
- Function
-
- Formats
- JavaScriptExpression
- PythonExpression
-
- External Evaluation Systems
- Python
- NodeJS
- Julia
- Java
- Octave
- Shell
- Ruby
- R
- Jupyter
- SQL
- SQL-JDBC
- Related Guides
- Workflows
-
See Also
ExternalFunction[sys,"f"]
represents an external function named "f" defined in the external evaluator sys.
ExternalFunction[session,"f"]
represents an external function "f" in the specified ExternalSessionObject.
ExternalFunction[sys,"code"]
represents an external function defined by the code fragment "code".
ExternalFunction[obj,"method"]
represents a method bound to the ExternalObject.


ExternalFunction[sys,"f"]
represents an external function named "f" defined in the external evaluator sys.
ExternalFunction[session,"f"]
represents an external function "f" in the specified ExternalSessionObject.
ExternalFunction[sys,"code"]
represents an external function defined by the code fragment "code".
ExternalFunction[obj,"method"]
represents a method bound to the ExternalObject.
Details

- In ExternalFunction[sys,"code"], "code" is typically a pure or lambda function in the external system.
- In ExternalFunction[sys, …], possible choices for sys include:
-
"Python" Python "NodeJS" JavaScript running through Node.js "Julia" Julia "Ruby" Ruby "R" R "Jupyter" Jupyter kernel
Examples
open all close allBasic Examples (3)
Create an external function using the absolute value function in Python:
Compute the absolute value of with the external Python function:
Return an object for a Python module:
Run a method from the module, using ExternalFunction:
Scope (6)
Define a lambda function in Python:
Use this Python function in the Wolfram Language:
Use a Python built-in function:
Use the external function to convert a string to a list:
Define a function using complex numbers:
Compute the argument of a complex number via the Python phase function:
In NodeJS, it is not enough to just define a function—you have to explicitly return the function for ExternalFunction to recognize it as a callable function:
ExternalFunction supports the same command specification as ExternalEvaluate:
Properties & Relations (5)
ExternalOperation can be used to extract the operation from an ExternalFunction:
Run the operation using ExternalEvaluate:
ExternalOperation can be used as an argument to ExternalFunction:
The executed operation is identical to the following one:
Which can be executed with ExternalEvaluate:
The result is equivalent to running the following Python code:
Create an ExternalFunction and an ExternalObject:
ExternalObject can be used as an argument to ExternalFunction:
The result is equivalent to running the following Python code:
Create an ExternalObject:
Use ExternalFunction to run methods on the object:
Create an ExternalObject for the datetime module:
Create an ExternalObject with the current date and another one with a timedelta:
Send back the objects using an ExternalFunction:
The same can be done with an ExternalEvaluate call:
Use "ReturnType" to return a String:
Applications (3)
Define a function in the session:
Create an ExternalFunction from this Python function:
Use the function within normal Wolfram Language code:
Import the Python NumPy package to load additional functionality:
It partitioned the list into a 3×4 matrix:
The equivalent Wolfram Language command:
Define a Python function that imports an image from a URL and rotates it:
The result is a ByteArray:
Import the ByteArray to display the rotated image:

See Also
ExternalEvaluate ExternalObject ExternalOperation StartExternalSession APIFunction FunctionCompile CloudFunction Function
Formats: JavaScriptExpression PythonExpression
External Evaluation Systems: Python NodeJS Julia Java Octave Shell Ruby R Jupyter SQL SQL-JDBC
Function Repository: ToPythonFunction
Related Workflows
Text
Wolfram Research (2019), ExternalFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/ExternalFunction.html (updated 2024).
CMS
Wolfram Language. 2019. "ExternalFunction." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/ExternalFunction.html.
APA
Wolfram Language. (2019). ExternalFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ExternalFunction.html
BibTeX
@misc{reference.wolfram_2025_externalfunction, author="Wolfram Research", title="{ExternalFunction}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/ExternalFunction.html}", note=[Accessed: 10-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_externalfunction, organization={Wolfram Research}, title={ExternalFunction}, year={2024}, url={https://reference.wolfram.com/language/ref/ExternalFunction.html}, note=[Accessed: 10-August-2025]}