Get this error when I run the first example python3 -m baselines.deepq.experiments.train_cartpole:
/usr/bin/python3: Error while finding spec for 'baselines.deepq.experiments.train_cartpole' (<class 'ImportError'>: cannot import name 'deepq')
I have both Python 2 and 3 installed. Thus I installed baselines with pip3.
Any suggestions?
I had the same issue as above. Any help will be appreciated !
I cannot reproduce it neither on linux nor on max. Can you provide more details?
i did my setup within virtualenv
i tried running one of the example command line: python3 -m baselines.deepq.experiments.train_cartpole
and i got the following error:
/usr/bin/python3: Error while finding spec for 'baselines.deepq.experiments.train_cartpole' (
When i tested it in python3:
1) import baselines
This is ok
2) from baselines import deepq
i got the following error:
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
import baselines
from baselines import deepq
i got the following error:
Traceback (most recent call last):
File "
File "/usr/local/lib/python3.4/dist-packages/baselines/deepq/__init__.py", line 4, in
from baselines.deepq.simple import learn, load # noqa
File "/usr/local/lib/python3.4/dist-packages/baselines/deepq/simple.py", line 12, in
from baselines import deepq
ImportError: cannot import name 'deepq'
I managed to solve the issue by installing Anaconda 3 and creating a Conda environment conda create -n tensorflow and then running the installation in this environment. More instructions are provided in the following:
https://www.tensorflow.org/install/install_linux#installing_with_anaconda
It seems like there's a workaround so I will close this issue.
If the issue persists, since it is difficult to reproduce, please specify a Dockerfile needed to reproduce it before reopening.
Do not install testflow seperately, install gym and baselines with pip3 and run with python3, everything should be ok.
But the program needs tensorflow as the backend, right? You must have installed it somewhere.
the issue seemed to be stemming from a recursive import error (i don't have know what i'm talking about) of deepq from baselines.deepq.simple.py
I changed some some code in simple.py to more explicitly point at the desired modules and it worked
modifications include:
edited line 12 to "from baselines.deepq.build_graph import build_act, build_train"
edited line 172 to " act, train, update_target, debug = baselines.deepq.build_graph.build_train("
added "import baselines" to file
@chenmin1107 , "pip3 baselines" will install testflow, if you look at lastest test flow installation, it can installed by pip3, do not have to install in virtualenv, I guess the virtualenv cause the issue.
I think it is a recursive import error and @Dangerpuss offers a practical solution. But it's still weird because in my case one machine with python 3.5 does not report this error while the other machine with python3.4 reports this error.
@Zhang-Yong thanks for the suggestion, but I want to set it up in a virtualenv so it won't mess my other things.
@yuke93 Same thing here, @Dangerpuss 's way works on my side as well. But I have not tried python3.5. Maybe it is just a python version issue.
Thanks @Dangerpuss I'm also confident that it's a python 3 versioning issue as @yuke93 indicates.
from baselines import deepq
Python 3.4: recursive import error, dangerpuss's edits fixed problem
Python 3.6: no issue
I'd say Python 3.5 and greater should work based on the responses.
in simple.py
Also edit line 25 to: act = baselines.deepq.build_graph.build_act(**act_params)
This is required we you run "python -m baselines.deepq.experiments.enjoy_cartpole"
You can replace,
from baselines import deepq by
from baselines.deepq.build_graph import build_act, build_train
it will work. This problem I faced while working with python 2.7
Most helpful comment
the issue seemed to be stemming from a recursive import error (i don't have know what i'm talking about) of deepq from baselines.deepq.simple.py
I changed some some code in simple.py to more explicitly point at the desired modules and it worked
modifications include:
edited line 12 to "from baselines.deepq.build_graph import build_act, build_train"
edited line 172 to " act, train, update_target, debug = baselines.deepq.build_graph.build_train("
added "import baselines" to file