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):
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:
- conda-forge: https://anaconda.org/search
- The search page houses a lot of channels, but we highly recommend choosing packages from the
conda-forge
-channel.
- The search page houses a lot of channels, but we highly recommend choosing packages from the
- pip: https://pypi.org/
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.
You can achieve the same result using RCC and its robot libs
command:
- 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:
You can achieve the same result using RCC and its robot libs
command:
- Use the
--add
parameter to specify the name and version of the package. - Use the
--conda
parameter to specify the path to theconda.yaml
file. - Use the
--pip
parameter to indicate that you want to install a pip package.