Setting up Python

Get your computer ready to work with Python and your collection data

This page walks you through everything you need to work with Double Dig IT software from Python. You will install an editor, Python itself, the .NET platform our software runs on and the Double Dig IT Python SDK. Finally, you will run a short test script to check that everything works.

Allow about half an hour. Using a laptop managed by your organisation? Step 3 requires administrator rights, so you may want to ask your IT department for help.

This guide is for macOS. Using Windows? See the steps for Windows.

Python
Step 1

Install Visual Studio Code

Visual Studio Code (VS Code) is a free editor from Microsoft for writing, running and debugging Python scripts. It is lightweight and works well with both Python and .NET.

  1. Download VS Code for macOS from code.visualstudio.com/download.
  2. Open the downloaded zip file and drag Visual Studio Code to your Applications folder.
  3. Start VS Code and open Extensions from the bar on the left (or press Cmd+Shift+X).
  4. Search for Python and install the Python extension by Microsoft.

Opening a terminal

In the next steps you will type a few commands in a terminal. You can open one directly in VS Code from the Terminal > New Terminal menu. A line where you can type commands then appears at the bottom of the window.

Every code block on this page has a button to copy its contents. Paste the command into the terminal with Cmd+V and press Enter.

Step 2

Install Python

Python is the programming language itself. On a Mac, you install Python with the installer from the official Python website.

  1. Go to python.org/downloads and click Download Python.
  2. Open the downloaded file and follow the installer.
  3. Open a new terminal and check that Python works by asking for its version number. On a Mac, the command is called python3.

Already have Python installed? Just check the version number. Version 3.11 or newer is fine.

Terminal: check the version
python3 --version
Expected result
Python 3.15.0

A higher version number is fine too.

Step 3

Install the .NET 10 Runtime

Double Dig IT software is built on .NET, Microsoft's software platform. To use this software from Python, your computer needs the .NET 10 Runtime.

  1. Go to the .NET 10 download page.
  2. Scroll to the .NET Runtime 10.0 section and, in the macOS row under Installers, click Arm64 if your Mac has an Apple chip (M1, M2 and so on), or x64 if it has an Intel processor. You can check which one you have via the Apple menu > About This Mac.
  3. Open the downloaded file and follow the installer. You will need your administrator password.
  4. Open a new terminal and check the installation with the command for this step.

Already have the .NET 10 SDK? It includes the runtime, so you can skip this step.

Terminal: check .NET
dotnet --list-runtimes

The list should contain a line starting with Microsoft.NETCore.App 10.0, for example:

Expected result
Microsoft.NETCore.App 10.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Step 4

Install the Double Dig IT Python SDK

The Python SDK contains the software that lets Python work directly with your collection data. Python talks to this .NET software through the pythonnet package, which you also install in this step.

  1. Download the Python SDK using the button below.
  2. Double-click the zip file in your Downloads folder (Safari sometimes does this for you). Then drag the DDigit-Python-SDK folder to your home folder, which you can open in the Finder via Go > Home.
  3. Install pythonnet with the command for this step.

Prefer a different location? That's fine. Just remember where you put the SDK, because you will need that path in step 5.

Terminal: install pythonnet
python3 -m pip install pythonnet

The installation ends with a line starting with Successfully installed. Seeing Requirement already satisfied instead? Then pythonnet was already installed, which is fine too.

Step 5

Test your setup

Now everything comes together. You will create a working folder with two small Python files and run a test.

  1. Create a folder for your scripts, for example ~/Python-CollectionData, and open it in VS Code with File > Open Folder.
  2. In that folder, create the file ddigit_bootstrap.py (File > New File) and paste the matching code into it. This file loads the Double Dig IT software, so your own scripts only need to import it. Put the SDK somewhere else? Then change the path at sdkPath.
  3. Create the file test_setup.py in the same way, with its matching code.
  4. Run the test script with the play button in the top right of VS Code (Run Python File), or type python3 test_setup.py in the terminal.

Do you see the word "Success!" appear in the terminal? Then your computer is ready to work with Python and collection data.

ddigit_bootstrap.py
import osimport sys# change this path if you put the SDK somewhere elsesdkPath = os.path.expanduser("~/DDigit-Python-SDK/dotnet")# add the SDK folder to the Python search pathsys.path.insert(0, sdkPath)# load the .NET runtime with the configuration from the SDKfrom pythonnet import loadload("coreclr", runtime_config=os.path.join(sdkPath, "DDigit.PythonHost.runtimeconfig.json"))# load the Double Dig IT DataProviderimport clrclr.AddReference(os.path.join(sdkPath, "DDigit.DataProvider.dll"))
test_setup.py
import sysimport ddigit_bootstrapfrom DDigit.DataProvider import DDataProviderdataProvider = DDataProvider()print("Python", sys.version.split()[0])print("Success! The Double Dig IT Python SDK is working.")
Expected result
Python 3.15.0
Success! The Double Dig IT Python SDK is working.

Not working?

Don't worry, most problems are quickly solved. Look up the error message you see in the list below.

command not found: python
On a Mac, the command is python3 rather than python. Already using python3? Then close all terminals and VS Code and open them again, so the new installation is picked up.
ModuleNotFoundError: No module named 'pythonnet'
Pythonnet is not yet installed for the Python version VS Code is using. Run the command from step 4 again. Then, in VS Code, press Cmd+Shift+P > Python: Select Interpreter and choose the same Python version as in the terminal.
ModuleNotFoundError: No module named 'ddigit_bootstrap'
Python cannot find ddigit_bootstrap.py. Make sure it is in the same folder as test_setup.py and that the file name is spelled exactly right.
RuntimeError: Can not determine dotnet root
Python cannot find .NET. Usually the .NET 10 Runtime has not been installed yet, so go through step 3. Installed .NET in another way, for example with Homebrew? Then install it again with the installer from step 3, so it ends up in the standard location.
RuntimeError: Failed to create a .NET runtime (coreclr)
Python cannot find .NET or the SDK. Check that the folder in ddigit_bootstrap.py contains the file DDigit.DataProvider.dll. Make sure you did not accidentally create an extra folder while extracting, such as DDigit-Python-SDK/DDigit-Python-SDK. Is the path correct? Then check step 3 and restart VS Code.

Still stuck? Get in touch and include the full error message, and we will help you out.

All set? Then you're ready to go!

You can now work with your collection data directly from Python. Have a question, or want help with your first scripts? Feel free to get in touch.

Learning Python

Want to learn more about Python itself? The official Python tutorial is a good place to start.

An unhandled error has occurred. Reload 🗙