You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
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
I'm using Mac and I'm trying out gym from openai, then I downloaded a project for which I needed stable-baselines so I followed the documentation and it didn't work so I thought maybe it's gym but gym works fine. I made a new project copy and pasted the example code on stable-baselines documentation, but it just keeps giving me the same error. I tried every way of downloading stable-baseline: pip, pip3, with and without mpi, I even tried downloading it via github and the bleeding-edge version. I already have CMake and openmpi
Code:
import gym
from stable_baselines.common.policies import MlpPolicy
from stable_baselines.common.vec_env import DummyVecEnv
from stable_baselines import PPO2
env = gym.make('CartPole-v1')
env = DummyVecEnv([lambda: env]) # The algorithms require a vectorized environment to run
model = PPO2(MlpPolicy, env, verbose=1)
model.learn(total_timesteps=10000)
obs = env.reset()
for i in range(1000):
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
env.render()
Error:
Traceback (most recent call last):
File "/Users/(my name)/Documents/testing gym.py", line 3, in <module>
from stable_baselines.common.policies import MlpPolicy
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/stable_baselines/__init__.py", line 4, in <module>
from stable_baselines.deepq import DQN
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/stable_baselines/deepq/__init__.py", line 1, in <module>
from stable_baselines.deepq.policies import MlpPolicy, CnnPolicy, LnMlpPolicy, LnCnnPolicy
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/stable_baselines/deepq/policies.py", line 2, in <module>
import tensorflow.contrib.layers as tf_layers
ModuleNotFoundError: No module named 'tensorflow.contrib'
System Info
Describe the characteristic of your environment:
I installed via pip(3), GitHub clone
I'm using a Mac with intel core i7 quad-core 2.6GHz and Radeo Pro 560X 4gb
My python version is python 2.7.11, python3 3.7.4
Tensorflow version: 2.0.0
gym version: 0.14.0
Please help
Tensorflow version: 2.0.0
That there is the problem: Stable-baselines is built for Tensorflow major version 1 (up till 1.14.0), and does not work for Tensorflow 2. You can change to working tensorflow version with pip3 install --upgrade tensorflow==1.14.0
.
I think this is a problem in stable-baselines as setup.py
attempts to install any tensorflow version up from 1.8.0, including 2.0.0.
When I ran the "Getting started" example I have the following error: "ModuleNotFoundError: No module named 'tensorflow.contrib'."
it seems there is tensorflow older than 2.1 is not available any more (at least on python 3.9) what should I do?
tanks