We will be going over the steps to set up the OpenAI Gym dependencies and other tools required for training your reinforcement learning agents in detail in Chapter 3, Getting Started with OpenAI Gym and Deep Reinforcement Learning. This section provides a quick way to get started with the OpenAI Gym Python API on Linux and macOS using virtualenv so that you can get a sneak peak into the Gym!
MacOS and Ubuntu Linux systems come with Python installed by default. You can check which version of Python is installed by running python --version from a terminal window. If this returns python followed by a version number, then you are good to proceed to the next steps! If you get an error saying the Python command was not found, then you have to install Python. Please refer to the detailed installation section in Chapter 3, Getting Started with OpenAI Gym and Deep Reinforcement Learning of this book:
- Install virtualenv:
$pip install virtualenv
- Create a virtual environment named openai-gym using the virtualenv tool:
$virtualenv openai-gym
- Activate the openai-gym virtual environment:
$source openai-gym/bin/activate
- Install all the packages for the Gym toolkit from upstream:
$pip install -U gym
- Test to make sure the installation is successful:
$python -c 'import gym; gym.make("CartPole-v0");'