Minimal install – the quick and easy way
The OpenAI Gym is a Python package and is available in the Python Package Index (PyPI) repository. You can use easy_install or pip to fetch and install packages from the PyPI repository. Pip is a package management tool for Python, which most of you might be familiar with if you have experience scripting in Python:
(rl_gym_book) praveen@ubuntu:~$pip install gym
That's it!
Let's quickly check the installation actually went fine by running the following code. Create a gym_install_test.py file under the ~/rl_gym_book directory, type/copy the following code into it, and save it. You can also download the gym_quick_install_test.py file from the book's code repository:
#! /usr/bin/env python
import gym
env = gym.make("MountainCar-v0") # Create a MountainCar environment
env.reset()
for _ in range(2000): # Run for 2000 steps
env.render()
env.step(env.action_space.sample()) # Send a random action
Let's try running the script:
(rl_gym_book) praveen@ubuntu:~/HOIAWOG$python gym_quick_install_test.py
This should pop up a new window showing a car/carton and a v-shaped mountain, and you should see the car moving left and right randomly. The mountain car window should look something like this screenshot:
You will also see some values printed out to the console/Terminal that look like this:
If you saw this happening, then rejoice! You now have a (minimal) setup of OpenAI Gym!