Setting up a Python environment

We recommend installing the labscript suite (regular or developer mode) in a virtual environment. This helps sandbox the codebase without interfering with (or being interfered with) your system Python installation, or Python environments used for other purposes. Below we outline how to create and activate a virtual environment for Anaconda Python and other CPython distributions (which we call ‘Regular’ Python here).

Anaconda Python

Anaconda Python includes a virtual environment manager as part of the conda executable. Below is an example (on Windows).

Note

Make sure you have opened the Anaconda Prompt on Windows (available from the Start menu). conda is not available from the standard terminal by default. Launching ‘Anaconda Prompt’ will activate the base conda environment.

Warning

We do not recommend using the base conda environment for any project (labscript suite or otherwise). Working in a separate conda environment ensures any package resolution or update errors (however unlikely) are limited to that environment, and base is not compromised.

Quickstart

When creating a new virtual enviornment, it is preferrable to specify the python version to use. You will need to specify a python version that is compatible with the labscript-suite. The currently compatible versions are PyPI pyversions. It is recommended to select a newer version of python for a new install, though some device drivers may require an older version of python to operate correctly.

(base) C:\> conda create -n labscript python=3.11
(base) C:\> conda activate labscript
(labscript) C:\>

Once activated, the name of the virtual environment (in this case, labscript ) will prefix the command line.

Detailed Instructions

  1. Create a virtual (conda) environment. Here we name it labscript and ask conda to use Python 3.11 within the virtual environment (name and Python version are variable but these are conventional choices):

(base) C:\> conda create -n labscript python=3.11
  1. Activate the virtual (conda) environment:

(base) C:\> conda activate labscript
(labscript) C:\>

Regular Python

There are a number of ways to configure a virtual environment. If you are unfamiliar with doing so, we recommend using the venv module, part of the Python Standard Library. Here’s an example (on Windows):

Quickstart

C:\Users\wkheisenberg> mkdir labscript-suite
C:\Users\wkheisenberg> cd labscript-suite
C:\Users\wkheisenberg\labscript-suite> python -m venv .venv
C:\Users\wkheisenberg\labscript-suite> .venv\Scripts\activate
(.venv) C:\Users\wkheisenberg\labscript-suite> python -m pip install --upgrade pip setuptools wheel

Once activated, the name of the virtual environment (in this case, .venv ) will prefix the command line.

Detailed Instructions

  1. From a new terminal, create a directory for the virtual environment and enter it. Here we use a directory named labscript-suite in the user’s home directory, also the location of the labscript suite profile directory. You need create the virtual environment here, but it is a convenient choice.

C:\Users\wkheisenberg> mkdir labscript-suite
C:\Users\wkheisenberg> cd labscript-suite
  1. Create a virtual environment. Here we name it .venv, located inside the labscript suite profile directory.

C:\Users\wkheisenberg\labscript-suite> python -m venv .venv
  1. Activate the virtual environment:

C:\Users\wkheisenberg\labscript-suite> .venv\Scripts\activate

Note

This step is OS specific, e.g. on Linux it’s source .venv/bin/activate.

  1. Update the Python package installer and other installation packages of your virtual environment.

(.venv) C:\Users\wkheisenberg\labscript-suite> python -m pip install --upgrade pip setuptools wheel

Choosing an installation method

Once you have a virtual environment up and running, choose from one of the following 4 installation methods:

  1. Regular installation (Python Package Index);

  2. Regular installation (Anaconda Cloud);

  3. Developer installation (Python Package Index); or

  4. Developer installation (Anaconda Cloud).