tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

TypeError: __init__() got an unexpected keyword argument 'new_step_api'

Open ddharshan opened this issue 3 years ago • 5 comments

Hi when i run the following Pytorch code in Jupyter notebook, i am getting the error as TypeError: init() got an unexpected keyword argument 'new_step_api'

Could you please help me on finding the solution for this problem ?

import gym import math import random import numpy as np import matplotlib import matplotlib.pyplot as plt from collections import namedtuple, deque from itertools import count from PIL import Image

import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torchvision.transforms as T

env = gym.make('CartPole-v0', new_step_api=True, render_mode='single_rgb_array').unwrapped

set up matplotlib

is_ipython = 'inline' in matplotlib.get_backend() if is_ipython: from IPython import display

plt.ion()

if gpu is to be used

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

cc @vmoens @nairbv

ddharshan avatar Oct 08 '22 06:10 ddharshan

Are you referring to this tutorial: https://pytorch.org/tutorials/intermediate/reinforcement_q_learning.html

malfet avatar Oct 11 '22 17:10 malfet

What is the version of gym you have installed on your system? (I assume you are not running it in Google Colab, are you?)

malfet avatar Oct 11 '22 17:10 malfet

hi, I am having the same issue, I have gym==0.24 version.

munirfarzeen avatar Oct 12 '22 13:10 munirfarzeen

We have recently updated this tutorial to use gymnasium==0.27.0. Is this still an issue after this update?

svekars avatar Mar 01 '23 23:03 svekars

It's running fine, now!

JDRanpariya avatar Oct 07 '24 13:10 JDRanpariya