Marko Grdinić
Marko Grdinić

Reputation: 4062

How to make the debugger step through the whole program?

import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(100):
    env.render()
    env.step(env.action_space.sample()) # take a random action

This is an example from the OpenAI gym. 'Step into' works neither on the import gym nor on any of the method calls for env, it just skips over them to the next statement. I am new to Python, but not to programming at this point.

In order to build intuition on how exactly gym and various Python libraries work I'd like as an exercise to go through them step by step. There is also a plotting issue in all the PyTorch examples and now this one where the window freezes after being run that has something to do with async handling.

Since I'd like to use Python specifically for its interactivity, I want to look into this. How could this be done?

Upvotes: 1

Views: 177

Answers (1)

Marko Grdinić
Marko Grdinić

Reputation: 4062

In Options -> Python -> Debugging there is a Enable debugging of the Python standard library option that needs to be enabled for stepping through the gym to work. I am not sure why Python or VS thinks that a random package like gym is a part of the standard library.

This applies to VS 2017.

Upvotes: 2

Related Questions