The OpenAI/Gym project offers a common interface for different kind of environments so we can focus on creating and testing our reinforcement learning models. In this tutorial I show how to install Gym using the most common package managers for Python.
The only prerequisite for basic installation of Gym is the Python 3.5+ interpreter and its package manager pip. Environments like Atari, Retro or MuJoCo have additional requirements.
pip install gym
For some Linux distributions and for MacOS the default Python commands points to a default installation of Python 2. If that’s the case, execute the Python 3 version of pip:
pip3 install gym
And that’s it. Also, if you want to install Gym with the latest merge, you can install it directly from its source code. You do that by cloning the Gym repository from Github and executing pip right away:
git clone https://github.com/openai/gym cd gym pip install -e .
(Don’t forget the dot at the end of last command)
By installing Gym using the default package, the following environments will be available for you:
- Toy Text
- Classic Control
Additional environments like Atari or MuJoCo must be installed separately, as they have dependencies that are not included with the default package.
If you use pipenv to manage the dependencies of your projects, the process to install Gym using pipenv is very similar. Just execute the following command inside your project:
pipenv install gym
Another option is install Gym using the conda package manager, although the available packages at conda repositories are not officially supported by the Gym team. You can install Gym using conda executing the following command:
conda install -c akode gym
The option -c akode indicates the channel in which conda must search for the gym package.
The steps to install Gym are very simple. However, additional environments may depend on native or proprietary dependencies that must be manually installed which can cause some hassle. For that reason, I recommend you install the basic packages first and then add new environments incrementally.
So, if even after following these steps you can’t execute gym or if you have any difficult on installing and executing a Gym environment, feel free to contact me at email@example.com and I will be very glad to help you.