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.

Prerequisites
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
The easiest way to install the Gym library is using the pip tool. In order to install the latest version of Gym all you have to do is execute the command:
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:
- Algorithmic
- 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.
pipenv
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
conda
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 questions@reinforcementelearning4.fun and I will be very glad to help you.
Yes, install gum is relative easy. However, to get a game running is not so lucky for me on Mac OS Catalina 10.15.3. Do you have any step-by-step guide to ABC of setting atari game? your reply are appreciated!
LikeLiked by 1 person
Hi, it is true that install gym is relatively easy. However, to firing an atari game is not so trivial on my Mac OS Catalian 10. 15. 3. Do you have a step-by-step guide for at least one atari game? Or which shell or IDE can mitigate the setup trouble? thanks in advance! David
LikeLiked by 1 person