Skip to content

Install

  • Visual Studio Code 1.110 or later. Check your version with Help > About (Code > About Visual Studio Code on macOS). You download it from the official VSCode website.
  • A Python environment, only to run models. You can explore, edit, draw and validate a model, and chart existing results, without Python.
  1. Open VS Code and open the Extensions view, with the icon in the activity bar or with Ctrl Shift X (Cmd Shift X on macOS).

  2. Search for Pywr and select the extension published by s-simoncelli.

  3. Press Install.

    The Python extension is installed with it, because it is used to select the Python environment.

You can also install it from its page on the Visual Studio Marketplace.

The extension starts when you open a JSON file. When the file is a Pywr model, the Pywr icon in the activity bar opens the sidebar with the components of the model.

To run a model, the extension needs a Python environment: a virtual environment or a conda environment. A system-wide Python is refused, so that running a model never depends on, or changes, the Python of your machine.

Pywr v2 is built into the extension, so you do not install it. The environment is used to process the Python parameters of your model and to read timeseries with pandas, polars or your own Python function.

  • Python 3.10 or later.
  • Install pyarrow in the environment if your model has Pandas, Polars or Python timeseries, plus pandas or polars for the first two.
  • Install any package your own Python parameters import.
  1. Open the folder with your model in VS Code (File > Open Folder…).

  2. Open a terminal in VS Code (Terminal > New Terminal) and create an environment in that folder:

    Terminal window
    python -m venv .venv
  3. For a Pywr v1 model, activate the environment and install pywr:

    Terminal window
    .venv\Scripts\activate
    pip install pywr
  4. Open the Command Palette with Ctrl Shift P (Cmd Shift P on macOS), run Python: Select Interpreter and pick the environment you created (.venv).

If a run fails with a message about the Python environment, see Troubleshooting.

Follow Your first model to create, run and chart a model, or open a model you already have and read Explore the model.