PyCharm with Robocorp
You can use the PyCharm IDE to develop robots for the Robocorp automation stack.
Robot Framework Language Server support
The Robot Framework Language Server for PyCharm provides:
- Code completion
- Code analysis
- Go to definition
- Browse Keywords (symbols)
- Syntax highlighting
Running and using RCC
We do not have a dedicated plugin available for RCC commands, so some manual bootstrapping is required, which is described in this article.
As a summary, with PyCharm and RCC, you can:
- create robots from templates
- run robots
- upload robots to Control Room
Also, many other advanced features are available with the help of the RCC command-line tool.
Install the tools
Download and install the following:
RCC is our command-line-based power tool used internally by our other tools, such as Robocorp Lab.
Verify that you can run
rcc version on a newly opened terminal window. If the command doesn't work, make sure it is found in PATH.
$ rcc version v5.0.12
Set up the environment
The Robocorp automation stack doesn't require you to install Python, Robot Framework, or other dependencies locally on your machine. Instead, the dependencies are isolated in lightweight virtual environments.
We need to manually create such an environment so that PyCharm can be later configured to use it.
Create a robot project from scratch
$ mkdir new-project $ cd new-project $ rcc robot initialize OK.
We now have the following files available:
$ ls conda.yaml output robot.yaml tasks.robot
conda.yaml file describes the dependencies for the project. Make sure you have the initial dependencies in place and then create a virtual environment based on the configuration file:
$ rcc environment new conda.yaml #### Progress: 0/4 [try use existing live same environment?]199ccc60-1f33-b256-ebcf-59efa2d205f4 #### Progress: 4/4 [Done.] [Stats: 25 environments, 139 requests, 20 merges, 105 hits, 1dirty, 25 misses, 5 failures | v5.0.12] Environment for [conda.yaml] as /Users/thatsme/.robocorp/live78c012d7204dd721e32630c3d0ed065b83e63788e40bf008adf503044ea9b80a409b56 created.
On the last line, we have the newly created virtual environment, which will be used later by PyCharm. Copy the path in your own terminal (it will not be the same as the example above).
Note: If the
conda.yamlfile is updated, the environment needs to be recreated. See details at Updating project dependencies.
Create a PyCharm project
Open PyCharm and select
+ New Project.
In the next dialog, set a name for the project and select
... next to
Existing Interpreter to define the project's environment.
We need to tell PyCharm to use the RCC environment that we created earlier on the command line.
We are using
bin/Python from that environment path. Additionally, we select
conda from the Robocorp configuration directory.
The Python path will have this format (on macOS):
Conda path is as follows on macOS:
Now, complete the project creation and check that the terminal inside PyCharm points to the right environment. We have Python and other dependencies available as defined by the
Create a run configuration
To be able to run the project with RCC, we will create a PyCharm run configuration.
Edit Configurations and add a new configuration with the
Shell Script and configure
rcc task testrun command as follows.
Note that the
Interpreter Pathis left empty.
Running the robot
After creating the run configuration, you can run the robot project from the Run menu. The test results are available in the
testrun folder. You may open the
log.html file in an external browser by right-clicking and selecting
Open In Browser -> Default.
Uploading the robot to Control Room
We will create a configuration to upload our robot to Control Room and to run in a cloud container. (Create your free account here: https://robocorp.com/robocorp-cloud).
On your plain command line, you can run the following commands (this is an option if you don't want to add a PyCharm configuration):
# Create credentials at https://cloud.robocorp.com/settings/access-credentials $ rcc configure credentials 849:b40ec2941659cf968bda88ae1ed1... Adding credentials: [849 b40ec2941659cf968bda88ae1...] OK. # Create new robot at workspace. Find workspace ID in Cloud workspace settings. $ rcc cloud new -r new-project-robot -w ad56bb1a-ea3b-492c-926... Created new robot named 'new-project-robot' with identity 3531. # Upload robot $ rcc cloud push -r 3531 -w ad56bb1a-ea3b-492c-926... OK.
We will create a run configuration for this specific robot and workspace. Note: you need to modify this if you want to use some other robot or workspace.
Edit Configurations and add a new Shell Script configuration with the
Similar to the previous test run configuration, we will add the required
We now have a command available to push our changes to Control Room quickly!
You can follow the same pattern and define your own commands for quick access.
This way, you will have the full power of RCC available on the command line and, at the same time, the nice editing capabilities of PyCharm.
Updating the project dependencies
When project dependencies are updated by editing the
conda.yaml file, a new virtual environment must be created.
Create an environment on PyCharm's terminal as follows:
$ rcc environment new conda.yaml #### Progress: 0/4 [try use existing live same environment?] 199ccc60-1f33-b256-ebcf-59efa2d205f4 #### Progress: 4/4 [Done.] [Stats: 25 environments, 150 requests, 26 merges, 110 hits, 1 dirty, 25 misses, 11 failures | v5.0.12] Environment for [conda.yaml] as /Users/mkaukoranta/.robocorp/live/fec012db304dd721e32630c390ed065b83e637c8e01bf0085df803049aa9bc0a409b56 created.
Add a new interpreter on the bottom right interpreter section:
Now configure the Conda-based environment to point to
bin/python of the newly created environment. Here we choose "Existing environment" as the environment has been already prepared with RCC:
You can now verify that new terminals in PyCharm open to the newly created environment and contain the correct dependencies according to the