'pip install gym package but import error given

I created my tensorflow env using conda (MacBook Pro), and installed manually all the tensorflow required packages following the apple developer website: https://developer.apple.com/metal/tensorflow-plugin/

Then, I pip installed gym and was trying to create the cartpole env:

import gym
env=gym.make('CartPole-v1')

However, I got an ImportError saying that the module pygame is not found:

enter image description here

Well, so I had to pip install pygame in this env. I thought that's because of some mistake I made while installing gym.

Since the env.render()in my Jupiter is not working properly, and I just want to test it out, I decided to move the code to Kaggle, where I think all the useful packages should already been installed. But unfortunately, I came across the exactly same error in Kaggle!

So here comes my question: what is going on with the gym package??? Should I conda install instead of pip install?? Why isn't the pygame installed along with gym? I'm confused. Please help! Thank you!

(BTW, the I'm still figuring out the env.render(), might have to post another question if it doesn't work also..)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source