Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
importing gym
#1
Hi everyone,

I did the pip install gym successfully in the anaconda prompt and now I am trying to run the following code in spyder and am getting an error.

import gym
env = gym.make("CartPole-v0")
import gym
env = gym.make("CartPole-v0")
C:\Users\SGrah\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):

File "<ipython-input-1-e6aa91c6b2ec>", line 21, in <module>
import gym

ModuleNotFoundError: No module named 'gym'

Any ideas as to why it is not working?
Reply
#2
use pip (or Conda) from Anaconda prompt

You cal always find which version of Python pip is associated with using:
pip -V
Reply
#3
I did that and got:

(base) C:\Users\SGrah>pip -V
pip 10.0.1 from c:\users\sgrah\anaconda3\lib\site-packages\pip (python 3.6)

How do I access gym tho? I believe it is already installed but it fails when I import in spyder
Reply
#4
can you import it?
just create a very simple python script testgym.py with:
import gym
and run from Anaconda Prompt

if you don't see any errors, you're good to go.

if you get error's, post entire session.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020