Before we start coding, we need to actually download the Python software, and the program in which we will write our code. Although you can write code directly into the terminal (on Mac) or command line (on Windows), this method is not very user-friendly. To help the productivity of programmers, many coding environments, or IDE’s (integrated development environment), have been made which can catch your coding errors as you write them, organize your files, and make coding more pleasing to the eye. There are a ton of these environments, but I recommend PyCharm, which is made by JetBrains. If you are familiar with programming already and have a different preferred IDE that can use Python, feel free to use that.
First, we will install Python itself. This will give us access to the Python interpreter, which can execute our Python code, as well as many built-in Python extensions, called packages. These packages are code, written by other programmers, which can be imported into our programs and used freely. The extensive list of Python packages are one reason why Python is our preferred choice for robotics.
Head to this link: https://www.python.org/downloads/.
There are multiple versions of Python, which differ slightly in their capabilities and compatibility with various packages. As of the time of writing this, I recommend downloading Python 3.7, since it has many of the current features of Python, while still being compatible with packages which haven’t been updated recently. To download, click the download link of Python 3.7.9 (most updated version of 3.7 at the time of writing this). Then, choose either macOS 64-bit installer for Mac users, or Windows x86-64 executable installer for Windows users. Open the installer, and follow the instructions.
Once Python is installed, we can install the PyCharm IDE. Go to https://www.jetbrains.com/pycharm/download/#section=windows, and select your operating system. Download the community installer, which is free and is enough for most programming you will ever do with Python. Then follow the installation instructions.
Whenever you want to start a new Python project, simply select “New Project” under the File tab of PyCharm. This will create a new folder inside the directory usr/PycharmProjects/. Then, you can make a Python file (where you write your code) by right clicking on the project folder inside PyCharm, and selecting new -> Python file. To run a Python file, or program, you can select the file in the IDE and press the green arrow in the top right.
Now you should have everything you need to start programming in Python. Continue to the next tutorial, where we will go over the print statement.
Comments