无法运行Pybrain教程

时间:2014-04-08 09:17:09

标签: python python-2.7 pybrain

我正在尝试运行其中一个tutorials,这就是我得到的:

$ python rl.py
Traceback (most recent call last):
  File "rl.py", line 22, in <module>
    from pybrain.rl.environments.mazes import Maze, MDPMazeTask
  File "/Library/Python/2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/rl/environments/mazes/__init__.py", line 3, in <module>
    from pybrain.rl.environments.mazes.tasks.__init__ import *
  File "/Library/Python/2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/rl/environments/mazes/tasks/__init__.py", line 1, in <module>
    from pybrain.rl.environments.mazes.tiger import TigerTask
ImportError: No module named tiger

它安装成功,不知道为什么它无法加载自己的模块?

2 个答案:

答案 0 :(得分:6)

您需要将文件:pybrain/pybrain/rl/environments/mazes/tasks/__init__.py更改为:

from pybrain.rl.environments.mazes.tiger import TigerTask

为:

from pybrain.rl.environments.mazes.tasks.tiger import TigerTask

答案 1 :(得分:0)

实际上,按照建议here,您应该更改整个pybrain / pybrain / rl / environments / mazes / tasks / init .py,如下所示:

from pybrain.rl.environments.mazes.tasks.tiger import TigerTask
from pybrain.rl.environments.mazes.tasks.maze import TrivialMaze, MazeTask
from pybrain.rl.environments.mazes.tasks.cheesemaze import CheeseMaze
from pybrain.rl.environments.mazes.tasks.tmaze import TMaze
from pybrain.rl.environments.mazes.tasks.maze4x3 import FourByThreeMaze
from pybrain.rl.environments.mazes.tasks.maze89state import EightyNineStateMaze
from pybrain.rl.environments.mazes.tasks.shuttle import ShuttleDocking
from pybrain.rl.environments.mazes.tasks.mdp import MDPMazeTask

检查pybrain.rl.environments.__file__以获取文件的路径。这解决了我的导入问题。