Show / Hide Table of Contents

Adding conda environments

Follow these steps to integrate conda environments into your SyncroSim package.

Using conda simplifies management of SyncroSim (or other) packages and dependencies. We highly recommend using this feature when creating a SyncroSim package using either R or Python. In this article, we will outline how to create packages that take advantage of conda environments. We detail how to create conda environments and how to add conda support to your SyncroSim packages.

Creating a conda environment

Step 1: Creating your conda environment

From your Windows search bar, begin typing "miniconda". Open the "Anaconda Powershell Prompt (miniconda3)" app that appears. Type in the following command to create a new environment and give it a name. In this example, the name will be new_env.

conda create -n new_env

If you want to create an environment using a specific version of Python (e.g. Python 3.10), you would instead type the following command:

conda create -n new_env python=3.10

If your desired environment has been shared with you using a YAML file, you can create the environment with the command below. In this example, the name of the YAML file will be helloworld.yml. Ensure the desired YAML file is located in your current working directory.

conda env create -f helloworld.yml
Note

Do not include any spaces in your environment’s name and follow any prompts to install necessary packages.

Activate your new conda environment with the following command:

conda activate new_env

Your new conda environment is now active.

Step 2: Installing packages

If you haven't already, you will need to configure the conda channel to install the necessary R or Python packages. The R and Python packages required for this tutorial are available from the conda-forge channel. Therefore, before installing, we must add the conda-forge channel to our conda configuration.

In the Anaconda Prompt (miniconda3) terminal, enter the following command:

conda config -–add channels conda-forge

Next, we will install the required packages.

  • R
  • Python

First we will install the base R package into our conda environment.

conda install r-base=4.1.3

The R extension of SyncroSim is called rsyncrosim. To install it, use the following command.

conda install r-rsyncrosim

Note that you can install more than one package at a time. For example, you can also install tidyverse and terra using the following command:

conda install r-terra r-tidyverse

When you are done modifying your environment, you can deactivate it.

conda deactivate

First we will install Python into our conda environment.

conda install python=3.10

The Python extension of SyncroSim is called pysyncrosim. To install it, use the following command.

conda install pysyncrosim

Note that you can install more than one package at a time. For example, you can also install gdal, numpy and pandas using the following command:

conda install gdal=3.7 numpy pandas

When you are done modifying your environment, you can deactivate it.

conda deactivate

Step 3: Exporting your conda environment

To add your conda environment to a custom SyncroSim package, you must export it to a YAML file. First, using the command cd, navigate to the folder where you would like to save your YAML file. For the purpose of this tutorial, we will navigate to the helloworld folder.

cd C:\temp\helloworld

Give a new name to your environment when you export it. In this example, the new name will be "environment". If your environment is currently active, you can export your environment using the following command:

conda env export > helloworld.yml

If your environment is not currently active, you can use the following command:

conda env export new_env > helloworld.yml
Note

For more information on creating conda environments, visit the conda documentation.

Adding conda support

To add conda support to your SyncroSim package, you must make a small change within the <transformer> tag of your package.xml. There are two new attributes called condaEnv and condaEnvVersion, where you specify the conda environment .yml file, and associated conda environment version respectively. Incrementing the condaEnvVersion number for your package will prompt the user installing the latest package release to also create the new version of the conda environment. As long as these attributes are present, SyncroSim will recognize that this package uses conda environments. Below, we use the example helloworld.yml file created in the section above.

  • R
  • Python
<transformer 
	name="Main" 
	displayName="Run Hello World (R)" 
	programArguments="model.R" 
	condaEnv="helloworldR.yml" 
	condaEnvVersion="1">
</transformer>
<transformer 
	name="Main" 
	displayName="Run Hello World (Python)" 
	programArguments="model.py" 
	condaEnv="helloworldPy.yml" 
	condaEnvVersion="1">
</transformer>

For more information on how to use SyncroSim packages with conda in the SyncroSim Studio, visit the conda tutorial.

What's next?

  • Enhance your package by incorporating more advanced features.
In This Article
Back to top Copyright 2007-2025 Apex Resource Management Solutions Ltd.
Generated by DocFX