Setting up the PyCharm IDE¶
This tutorial will guide you through setting up the PyCharm editor with support for our robot software. This means that the editor can do a better job of checking your code and suggesting as you type, saving you wasting time transferring your code to your robot only to find that a variable name has been mispelt, or something equally menial!
First, open up PyCharm from the Start Menu:
It may ask you to read and accept their terms and conditions before you can proceed:
Firstly, we will need to create a new project.
Next, you will need to configure the environment for your project. This ensures that we are using a compatible version of Python (3.6 or later), and that Pycharm is aware of the other code running on, and controlling your robot.
At the top of the dialogue box, choose an appropriate location to save your code.
If you are using a university computer, files that are placed in your
H:/ drive will
be synchronised and backed up across any other university computer.
Select New Environment using Virtualenv, and Python 3.6 for the base interpreter.
The location of Python 3.6 may vary by computer. Ask a volunteer for help if you are stuck.
Once PyCharm has finished loading, we need to create a new
Right-click on your project name, select New -> Python File.
You will need to name your file
main.py or your robot will not recognise it.
In order to get suggestions as you type your code, you’ll need to install the same Python package that is used on your robot, which is called
sbot. You can do this by opening PyCharm’s settings, navigating to the “Project Interpreter” tab, and pressing the Install button:
Enter “sbot” into the search bar and ensure it is selected in the pane on the left, then press “Install Package”. This will take some time, so wait for the green success message.
You are now ready to program your robot. Pycharm will give you auto-suggestions and let you know if your code is mis-spelt or has other common errors.