pytorch / pytorch/tutorials

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

Open
#2,077 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Reinforcement Learning
Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Jupyter notebook snippet that calls gym.make for CartPole-v0 with new_step_api and render_mode. Check the tutorial's expected dependency versions and the installed Gym API; done means the example runs without this TypeError or clearly documents the compatible setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python, pytorch
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.