Adding packages to your robot

One of the Robocorp automation stack advantages is that you can benefit from the extensive ecosystem of Python libraries, freely available.

When you create a new project using our development tools, you will get a ready-to-go base environment. The environment will include the rpaframework package, giving you access to the RPA Framework set of open-source libraries supported and developed by Robocorp. You can add more features to your robot by adding more libraries and packages, or even remove the package if your code does not need it. Let's see how!

A small introduction: conda-forge and pip

The Robocorp automation stack uses the conda-forge open-source dependency management system to simplify the management of Python environments. Check the environment control page for more details.

Key thing to realize is that conda-forge is not limited to just Python.
šŸ‘‰ How about loading Firefox browser inside your robot, without installations on the target machine.

As often happens in the open-source world, this is not the only solution available: another popular package management system for Python modules is pip. Conda-forge is a newer initiative, so not all packages are available for both systems. For this reason, we decided to support both systems.

Should I use conda-forge packages or pip packages?

Conda-forge has a more efficient way to install packages and manage dependencies, which results in better and faster performance when setting up environments. So, if the library or module you are interested in is available as a conda-forge package, we recommend going with it. As a general rule, only use the pip version of a package if it is not available in conda-forge.

The conda.yaml file

The conda.yaml file (see default project structure) defines the environment your robot will run in. The default conda.yaml file you get when creating a new project looks something like this (comments added for clarity):

# For more details on the format and content: # https://github.com/robocorp/rcc/blob/master/docs/recipes.md#what-is-in-condayaml # Tip: Adding a link to the release notes of the packages helps maintenance and security. channels: - conda-forge dependencies: # Define conda-forge packages here -> https://anaconda.org/search # When available, prefer the conda-forge packages over pip as installations are more efficient. - python=3.9.16 # https://pyreadiness.org/3.9/ - pip=22.1.2 # https://pip.pypa.io/en/stable/news/ - pip: # Define pip packages here -> https://pypi.org/ - rpaframework==24.0.0 # https://rpaframework.org/releasenotes.html

When given this configuration file, rcc will:

  • Use the conda-forge channel
  • Install a specific version of Python (which is available as a conda-forge package)
  • Install a specific version of pip
  • Install a specific version of rpaframework

Where do I find packages?

Both systems provide web interfaces to search for supported packages:

How do I add new packages?

Once you found the package you want to use, add it to the correct section of the conda.yaml file. This can be done manually or automated using RCC, our command-line tool.

Adding conda-forge packages

For example, if your robot requires the numpy package, which is available as a conda package, you can add it under the dependencies YAML attribute. In this case, we are specifying the latest version at the time of writing.

channels: - conda-forge dependencies: - python=3.9.16 - pip=22.1.2 - numpy=1.23.0 # Numpy added here - pip: - rpaframework==24.0.0

You can achieve the same result using RCC and its robot libs command:

rcc robot libs --add numpy=1.23.0 --conda conda.yaml
  • Use the --add parameter to specify the name and version of the package.
  • Use the --conda parameter to specify the path to the conda.yaml file.

Adding pip packages

For example, if your robot requires the robotframework-datadriver Robot Framework library, which is only available as a pip package, you will have to add it under the pip attribute:

channels: - conda-forge dependencies: - python=3.9.16 - pip=22.1.2 - pip: - rpaframework==24.0.0 - robotframework-datadriver==1.8.1 # robotframework-datadriver added here:

You can achieve the same result using RCC and its robot libs command:

rcc robot libs --pip --add robotframework-datadriver==1.8.1 --conda conda.yaml
  • Use the --add parameter to specify the name and version of the package.
  • Use the --conda parameter to specify the path to the conda.yaml file.
  • Use the --pip parameter to indicate that you want to install a pip package.
Last edit: December 21, 2022