Running Python Code from External Editors
It is possible to edit and execute Python scripts within an Isaac Sim application (as it is done using the Omniverse Script Editor) using external editors. This makes it possible to take advantage of the features of the editors allowing for a better development.
The following editors are covered under this section:
VS Code
The omni.isaac.vscode
extension allows you to edit and execute Python scripts from the VS Code editor.
This extension is enabled by default (it can be enabled or disabled using the Extension Manager by searching for omni.isaac.vscode
).
Note
This extension requires its Visual Studio Code pair extension: Isaac Sim VS Code Edition to be installed and enabled in the VS Code editor in order to execute Python scripts on a running Isaac Sim instance.
To begin, enable this extension using the Extension Manager by searching for
omni.isaac.vscode
.Once the extension is enabled, go to the top menu bar and click on Window > VS Code to open the Isaac Sim folder in a VS Code application.
From the VS Code app, use the Isaac Sim VS Code Edition container in the Activity Bar (the one with the Isaac Sim logo)
Hint
Try it yourself!
you can use this code snippet to test if things are working. Create a new python file in the VS Code editor file with the following, save it, and then click the green Run button on the left side of the Isaac Sim VS Code Edition container.
1from pxr import Usd, UsdGeom
2import omni
3
4stage = omni.usd.get_context().get_stage()
5xformPrim = UsdGeom.Xform.Define(stage, '/hello')
6spherePrim = UsdGeom.Sphere.Define(stage, '/hello/world')
JupyterLab / Jupyter Notebook
The omni.isaac.jupyter_notebook
extension allows you to to open a JupyterLab (or Jupyter Notebook) app in the current Isaac Sim application scope.
To begin, enable this extension using the Extension Manager by searching for
omni.isaac.jupyter_notebook
.Note
This may take several seconds (and Isaac Sim will freeze) if this is the first time the
omni.isaac.jupyter_notebook
is enabled. Several Python dependencies will be installed.Once the extension is enabled, go to the top menu bar and click on Window > Jupyter Notebook to open a Jupyter app in the default web browser.
In the Jupyter app, click on the Omniverse (Python 3) kernel (the one with the Omniverse logo) to create a new Untitled notebook.
Execute code by clicking the Run button at the top of the notebook. Try it yourself with the same code snippet from above!
Warning
The Omniverse (Python 3) kernel is designed to run Python code, via the
omni.isaac.jupyter_notebook
extension, on a running Isaac Sim instance (where the Kit application has control over the update/simulation loop).The Isaac Sim Python 3 kernel is used to run standalone applications in Live Sync mode (see the Jupyter Notebook tutorial for more details).
Warning
Execution of blocking code freezes Isaac Sim.
Hint
Use the Tab key for code autocompletion.
Use the Ctrl + I keys for code introspection (display docstring if available).
Note
The notebooks are saved, by default, in a folder within the extension itself: exts/omni.isaac.jupyter_notebook/data/notebooks
. See the location for Isaac Sim packages/extensions in Common Path Locations.
Limitations
IPython magic commands are not available.
Matplotlib plotting is not available in the notebooks.
Printing, inside callbacks, is not displayed in the notebooks but in the Omniverse terminal.