Running Python 3 code in the interactive console
- Open a console view: Window > Console.
- Use the New Console drop-down and choose Python Console.

- Select "Python console" in the next dialog box.
- Enter your Python 3 code...

Running Python 3 code from the Python Editor
- Create a new project.
- Open the Project properties: Right-click on the project and choose "Properties" (or use Alt+Enter)
- Select section "Python - Interpreter" and switch the Project type to "Python":

- Create a new Python script in the "scripts" folder
- Focus the Python Editor and hit F9. The script will be run with the configured Project Python Interpreter.
- Any print output or error messages will appear in a correspondingly named output console:

Managing Python Interpreters
Python 3 interpreters can be managed in the Python Preferences at Preferences > Python > Interpreters > Python Interpreters

It is recommended to use separate virtual environments for larger Python scripts and minimize sharing the environments across projects. This allows independent management of 3rd party packages without affecting other projects.
Note:
In this Beta release of the Python 3 API, UI support for managing custom virtual environments is limited and therefore requires configuration on the command line (see below).Creating custom virtual environments for CityEngine
In the following, let "ce_python_home" be the location of the CityEngine Python support files:
- On Windows, this is "C:\Program Files\ArcGIS\CityEngine2025.1\plugins\com.esri.pythonbridge.win32.win32.x86_64_xxx"
- On Linux, this is "${HOME}/arcgis/cityengine2025.1/plugins/com.esri.pythonbridge.gtk.linux.x86_64_xxx"
Let "api_version" be the version of the "cityengine" API package, for example "0.0.1+ce2025111624" in above screenshot (the actual value changes per release).
- Open a command line terminal.
- To create a new virtual environment, run the following command (on Linux, use `python3.11` from the system path instead): "[ce_python_home]\python\python.exe" -m venv [new virtual environment location]
- Add the "cityengine" API package to your new virtual environment:
[new virtual environment location]\Scripts\python.exe -m pip install [ce_python_home]\api_pkg_cache\cityengine-[api_version]-py3-none-any.whl
- In the CityEngine interpreter manager, choose New > Browse for python/pypy.exe and navigate to "[new virtual environment location]\Scripts\python.exe" (on Linux, it is "[new virtual environment location]/bin/python").
- Give it a distinct name:

- The intepreter from the new virtual environment is now listed, including the "cityengine" API package:

See also