Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment isn't getting created upon running test_policy_gradients.py #1

Open
sankethvedula opened this issue Apr 16, 2017 · 14 comments

Comments

@sankethvedula
Copy link

Hi,

I am kind of new to this OpenAI Gym.

While I was trying to run the test_policy_gradient.py file, I am getting the following error.

[2017-04-16 07:51:37,265] policy_gradient logger started.
[2017-04-16 07:51:37,266] Making new env: trading-v0
Traceback (most recent call last):
  File "test_policy_gradient.py", line 17, in <module>
    env = gym.make('trading-v0')
  File "/home/ubuntu/gym/gym/envs/registration.py", line 161, in make
    return registry.make(id)
  File "/home/ubuntu/gym/gym/envs/registration.py", line 118, in make
    spec = self.spec(id)
  File "/home/ubuntu/gym/gym/envs/registration.py", line 147, in spec
    raise error.UnregisteredEnv('No registered env with id: {}'.format(id))
gym.error.UnregisteredEnv: No registered env with id: trading-v0

trying to debug, I included " import gym_trading" in the beginning of the file.

Now, I am facing the following error
unnamed 1

I understand that for some reason, the data frame isn't getting downloaded when I "make" the gym to create an environment, which is why I suspect I am getting this error.

Could you please point out where I am going wrong? Or if there is any fix around this?

Thanks a lot in advance!
Sanketh

@baolinliu
Copy link

this worked for me, it is in the init.py file in he gym_trading folder

from gym.envs.registration import register

register(
id='trading-v1',
entry_point='gym_trading.envs:TradingEnv',
timestep_limit=1000)

@ackdav
Copy link

ackdav commented Jun 7, 2017

I'm having the same issue - and both proposed solutions didnt work...

@ackdav
Copy link

ackdav commented Jun 7, 2017

here is the error:

[2017-06-07 14:21:50,524] policy_gradient logger started.
[2017-06-07 14:21:50,524] Making new env: trading-v0
Traceback (most recent call last):
  File "envs/test_policy_gradient.py", line 16, in <module>
    env = gym.make('trading-v0')
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 161, in make
    return registry.make(id)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 118, in make
    spec = self.spec(id)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 147, in spec
    raise error.UnregisteredEnv('No registered env with id: {}'.format(id))
gym.error.UnregisteredEnv: No registered env with id: trading-v0

tried importing gym_pull as suggested, but "no module named gym_trading"

@baolinliu
Copy link

id='trading-v1', called the environment v1

@ackdav
Copy link

ackdav commented Jun 9, 2017

@baolinliu thanks but how does that help? Now it's:
gym.error.UnregisteredEnv: No registered env with id: trading-v1

@ackdav
Copy link

ackdav commented Jun 10, 2017

I tried around for a few days, but in the end it worked with sudo pip install -e . I'm not sure why using the -e flag made it work.

also I had to move the register call into test_policy_gradient.

Additionally with newer gym version you'd need to call env=env.unwrapped

@lwhuang
Copy link

lwhuang commented Jul 3, 2017

can't get it work.
what's the install procedure?
pip install -e .
shows
Running setup.py develop for gym-trading
Successfully installed gym-trading

but still gym.error.UnregisteredEnv: No registered env with id: trading-v0

@crescentluna
Copy link

according to registration.py of gym library, env object is wrapped in a TimeLimit object
env = TimeLimit(env, max_episode_steps=env.spec.max_episode_steps,max_episode_seconds=env.spec.max_episode_seconds)
so use env.env to run those methods such as run_strats

@sophieyl
Copy link

sophieyl commented Feb 6, 2018

the reason is that the environment did't register into the gym module.
change the init.py file in the same directory with env as below:
from gym.envs.registration import register

register(
id='trading-v0',
entry_point='gym_trading.envs.trading_env:TradingEnv',
timestep_limit=1000,
)
the entry_point should be 'gym_trading.envs.trading_env:TradingEnv'

@erdult
Copy link

erdult commented Apr 22, 2018

still not working

@melseifi
Copy link

Not working for me either. If I include import gym_trading, it doesn't pass this step. and if I comment it, I get the registration error above.

@wongchunghang
Copy link

wongchunghang commented Dec 18, 2018

After some packages update(e.g. the gym module), the notebook in the github will throw errors. So I fixed some of the issues and also made the corresponding changes required so that it can run smoothly in colab.
You may find the colab notebook link here: https://colab.research.google.com/drive/14OIx32e_pzqpMIhhRcPV5CMAHUAwVQK1

@WilliamGast
Copy link

After running this code:

trading_environment = gym.make('trading-v0',
ticker='AAPL',
trading_days=trading_days,
trading_cost_bps=trading_cost_bps,
time_cost_bps=time_cost_bps)
trading_environment.seed(42)

I get an assertion error and I don't know how to get past it if anyone can help.

@RoyZhangxiquan
Copy link

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests