Skip to content

Getting Started with Command‐Line

Carole Hayakawa edited this page Jun 11, 2025 · 8 revisions

Using VTS with Python Scripts

This information will likely change as more support for python and .NET is introduced.

Installation details

Step 1: Install .NET 8

You will need version 8 of .NET which is available from Microsoft below

https://dotnet.microsoft.com/en-us/download/dotnet/8.0

On Ubuntu Linux:

Do not forget to update your ~/.bashrc or whatever you use so that this directory is in your path. Also define DOTNET_ROOT

export DOTNET_ROOT=/usr/share/dotnet
PATH=$PATH:$DOTNET_ROOT

Install pip

sudo apt install python3-pip

Step 2: Clone the scripting repository

git clone https://github.com/VirtualPhotonics/vts.git

Step 3: Download the VTS libraries

Get the latest VTS libraries for the specific platform from releases and extract them into the libraries folder under scripting.

Step 4: Install pythonnet, numpy, plotly, scipy (list may grow as we add examples)

pip install pythonnet
pip install numpy
pip install plotly
pip install scipy

Note for MacOS and Linux: Because pythonnet under macOS (or linux) defaults to mono, two more things need to added to ~/.bash_profile

export PYTHONNET_RUNTIME=coreclr
export PYTHONNET_PYDLL=/usr/local/bin/python3 (MacOS)
export PYTHONNET_PYDLL=/usr/bin/python3 (Linux)

Use the path for python on your system (which python3 will tell you)

Step 4: Run programs

To run VTS programs in python3 include the following the header

    import clr
    import os
    file = '../libraries/Vts.dll'
    clr.AddReference(os.path.abspath(file))
    import numpy as np  
    import plotly.graph_objects as go  
    from Vts import *
    from Vts.Common import *
    from Vts.Extensions import *
    from Vts.Modeling.Optimizers import *
    from Vts.Modeling.ForwardSolvers import *
    from Vts.SpectralMapping import *
    from Vts.Factories import *
    from Vts.MonteCarlo import *
    from Vts.MonteCarlo.Sources import *
    from Vts.MonteCarlo.Tissues import *
    from Vts.MonteCarlo.Detectors import *
    from Vts.MonteCarlo.Factories import *
    from Vts.MonteCarlo.PhotonData import *
    from Vts.MonteCarlo.PostProcessing import *
    from System import Array, Object

Python Scripts

Clone this wiki locally