How can i import rl in python?

540 views Asked by At

i'm working at a Machine Learning project and i need to import different libraries but i don't know why i'm not able to import rl. I solved the same problem for tensorflow editing the syntax but i cannot find how to solve for rl. This is the .py [![enter image description here][1]][1]

from tensorflow.python.keras.engine import keras_tensor
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import Dense,Flatten
from tensorflow.python.keras.optimizers import adam_v2
from tensorflow.python.keras.utils import generic_utils


from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy 
from rl.memory import SequentialMemory 

and the problem on the prompt is the following one.

Inteligence/ML_Car_Pole/gim.py", line 12, in <module>
    from rl.agents.dqn import DQNAgent
  File "/opt/homebrew/lib/python3.11/site-packages/rl/agents/__init__.py", line 2, in <module>
    from .dqn import DQNAgent, NAFAgent, ContinuousDQNAgent
  File "/opt/homebrew/lib/python3.11/site-packages/rl/agents/dqn.py", line 8, in <module>
    from rl.core import Agent
  File "/opt/homebrew/lib/python3.11/site-packages/rl/core.py", line 8, in <module>
    from rl.callbacks import (
  File "/opt/homebrew/lib/python3.11/site-packages/rl/callbacks.py", line 12, in <module>
    from keras.utils.generic_utils import Progbar
ModuleNotFoundError: No module named 'keras.utils.generic_utils'

but if i remore the three import related to rl the file run correctly

1

There are 1 answers

4
shr4pnel On

it sounds like you should probably reinstall rl, and if that fails, try python3 -m pip install keras. If both of these fail, it sounds like a problem with the package itself. Maybe you've installed a broken nightly build?