pip install -U ovito
For further information, please refer to https://pypi.org/project/ovito/.
If you work with an Anaconda or Miniconda environment, you should use the following conda install command line:
conda install --strict-channel-priority -c https://conda.ovito.org -c conda-forge ovito=3.9.2
ovito conda package is hosted in our conda channel https://conda.ovito.org. It can easily be confused with
the ovito package found in the popular conda-forge channel.
The latter includes only OVITO Basic but not the Python module. To make sure you’ve installed the right package version,
run conda list and check if the source channel of the installed package is https://conda.ovito.org and not conda-forge.
OVITO Pro integrated interpreter
The OVITO Pro program package includes a preconfigured Python interpreter (commonly referred to as “ovitos”).
This interpreter comes pre-equipped with the
ovito Python module and all other things necessary to execute Python code within the OVITO Pro
desktop application. The ovitos interpreter may also be invoked externally, from a system terminal, to run standalone Python scripts
on the command line:
ovitos [-o <file.ovito>] [-g] [<script.py>] [args...]
The ovitos executable is located in the
bin/ subdirectory of OVITO Pro for Linux, the
Ovito.app/Contents/MacOS/ directory of OVITO Pro for macOS, and the main application directory
of OVITO Pro for Windows. It should not be confused with ovito, which is the executable that launches
the graphical desktop application. Both programs access the same integrated Python engine and ovitos
serves as a stand-in for the python executable, which allows running Python scripts from the command line
in OVITO Pro’s integrated interpreter.
Let’s say you’ve written a simple Python script file named
import ovito print("Hello world, this is OVITO %i.%i.%i" % ovito.version)
You can execute the script from a system terminal as follows:
user@linux:~/ovito-pro-3.9.2-x86_64/bin$ ./ovitos hello.py Hello, this is OVITO 3.9.2
ovitos is a console program that behaves almost like a regular python interpreter.
It lets you easily run scripts on remote machines or computing clusters that don’t possess a graphical display.
Any command line arguments following the script name will be passed to your Python program via
Invoking ovitos without a script filename starts an interactive interpreter session.
While you can also use any other Python interpreter to execute Python programs that import the
(after installing the module in that interpreter), ovitos relieves you from installing
ovito module and provides a few extra capabilities, which are described in the following sections.
Preloading session state
The -o command line option tells ovitos to load an
.ovito session state file before executing your
script. This allows you to preload an existing data pipeline or visualization setup that you have
previously prepared using the OVITO Pro or OVITO Basic desktop applications. All script actions will subsequently be performed in the context of this preloaded session.
This approach can save you programming work because things like modifiers and the camera setup already get loaded from the state file, and
you don’t need to set everything up programmatically in your script anymore.
The -g command line option of ovitos starts a graphical program session of OVITO Pro, and the script
will be run in the context of this GUI session. This lets you directly observe your script’s actions as they are being
executed. This function is useful for debugging purposes if you want to visually check the outcome of your script’s actions during the
development phase. Keep in mind that the viewports will only show pipelines that have been inserted into the current scene
Number of CPU cores
OVITO uses all available processor cores by default to perform certain computations. To explicitly restrict the program to a smaller number of parallel threads, use the --nthreads command line parameter, e.g. ovitos --nthreads 1 myscript.py. See Controlling how many processor cores OVITO uses.
Installing third-party Python modules
ovitos is a preconfigured CPython interpreter with the
ovito Python package already built in. This makes it possible to run scripts both within the OVITO Pro desktop application as well as through the ovitos
command line tool. However, OVITO Pro’s embedded Python interpreter only ships with very few third-party packages, namely NumPy and matplotlib.
If you want to call other third-party Python packages from your script, you can install them in the ovitos interpreter using the usual pip install mechanism. Simply run
ovitos -m pip install --user <package_name>
from a system terminal to install any package from the PyPI repository. This will make the package also available to scripts running in the context of a graphical OVITO Pro session.
The described approach only applies to OVITO Pro installed via installers from www.ovito.org. If you work with the Anaconda version of OVITO Pro, use the conda install command to add additional packages to the Python interpreter shared by OVITO Pro and your Anaconda environment.
Installing a Python extension via pip that includes native code may fail if it is not compatible with the build-time configuration of the ovitos interpreter. In such a case, using the Anaconda version of OVITO Pro is recommended, which makes installing third-party packages straightforward.