In this course, I want you to start coding as soon as possible. Therefore, we will start the course by installing a Python package called Gym. Gym is a Python package that offers a practical hands-on way of learning about Reinforcement Learning. You will be able to pickup the basic concepts of Reinforcement Learning while you are coding if you use this package. So let's install it.
https://github.com/openai/gym#supported-systems If we look at the README file in Gym's GitHub repository, we see that Gym is supported on Linux and MacOS. Windows support is experimental. I recommend that you use Linux or MacOS for this course. If you must use Windows, I recommend using a virtual machine with a Linux installation. I have put a link in the lecture notes which can help you with setting up a virtual machine with Linux. You will be able to do most of this course using such a setup, but you might have trouble using your GPUs. Therefore, the better way is to simply use a Linux or MacOS operating system.
I am going to demonstrate the installation of OpenAI Gym on a Ubuntu 18.04 system. Please carry out the steps in your own computer. The steps are the same for MacOS, but the command for installing system packages is different.
First, update the system packages. sudo apt-get update && sudo apt-get upgrade.
Then create a folder called rl_course and go into that folder. mkdir rl_course && cd rl_course. You are going to do all your work for this course inside this folder.
Now we will install the Python package Gym.
https://github.com/openai/gym#supported-systems Please make sure that you have Python 3.5 or higher for this course. You can check this by typing python3 --version. As you can see, I have version .... If you have a lower Python version, please install Python 3.5 or higher.
https://github.com/openai/gym/issues/809 Python packages like Gym can be installed in many ways. You can use a system installation. I would discourage a system installation as this leads to all python packages used by all of your projects to be in one place. If two projects use different versions of the same package, then this can lead to problems. It's better to install Python packages in project specific sandboxes so that projects can manage their Python package independent of other projects. There are two ways of doing that. You can use a Python virtual environment. You can also use Conda. Unfortunately, Conda doesn't officially support Gym yet. Therefore, I recommend a Python virtual environment installation.
There are many ways to create virtual environments and manage them. I am going to use the method that is most uniform across OS and Python versions.
Install the virtualenv package by typing python3 -m pip install virtualenv.
Create the virtual environment python3 -m virtualenv venv This will create a folder called venv. This folder is a sandbox which will contain all the Python packages that we install for this course.
Before you start working on the project, you must activate the sandbox. You do that by typing source venv/bin/activate. This ensures that any subsequent pip install command will install the packages in the virtual environment and not in the system Python. If the command worked, you will see the name of the virtual env in the command line prompt.
Similarly, when you want to deactivate the sandbox, simply type deactivate in the command line. This will deactivate the virtual environment and the name will disappear from the command prompt.
So activate your virtual environment and update pip pip install --upgrade pip.
Install gym[box2d] using pip. The Box2D environments are available after this step.
Install gym[atari] using pip. The Atari environments are available after this step. Do this when introducing the first Atari environment in the course.
Setup
sudo apt-get update && sudo apt-get upgrade
before recording.Steps
sudo apt-get update && sudo apt-get upgrade
.rl_course
and go into that folder.mkdir rl_course && cd rl_course
. You are going to do all your work for this course inside this folder.python3 -m pip install virtualenv
.python3 -m virtualenv venv
This will create a folder called venv. This folder is a sandbox which will contain all the Python packages that we install for this course.source venv/bin/activate
. This ensures that any subsequentpip install
command will install the packages in the virtual environment and not in the system Python. If the command worked, you will see the name of the virtual env in the command line prompt.deactivate
in the command line. This will deactivate the virtual environment and the name will disappear from the command prompt.pip install --upgrade pip
.pip install gym
.Check the installation with the following code
If the image pops up, this means your installation is successful.
Related to
gym[box2d]
when we first encounter aBox2D
environment in the course.gym[atari]
when we first encounter anAtari
environment in the course.I have tested that the following sequence of installation steps work smoothly.
gym
usingpip
. The classic control environments are available after this step. We are doing this in this lesson.Box2D
environment in the course.gym[box2d]
usingpip
. TheBox2D
environments are available after this step.gym[atari]
usingpip
. TheAtari
environments are available after this step. Do this when introducing the firstAtari
environment in the course.