![Hands-On Intelligent Agents with OpenAI Gym](https://wfqqreader-1252317822.image.myqcloud.com/cover/567/36699567/b_36699567.jpg)
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:
![](https://epubservercos.yuewen.com/F87B1A/19470390008867106/epubprivate/OEBPS/Images/28aeec58-bd81-45f3-be9f-4c7fbdb9ee89.png?sign=1739124926-FeBWDSarczfV9TP0UivCO5gUtR1lMCRQ-0-d22b83a0bb6ba4290a0be88cddef0da5)
You will also see some values printed out to the console/Terminal that look like this:
![](https://epubservercos.yuewen.com/F87B1A/19470390008867106/epubprivate/OEBPS/Images/8af07e94-7e62-4aee-b78e-3a6e97ff046c.png?sign=1739124926-V8JwwusqdiD29J302oFDMMlqhOD0bDuA-0-1ff3c5da4bce67dbf10df0a4ef2e7b77)
If you saw this happening, then rejoice! You now have a (minimal) setup of OpenAI Gym!