Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError: No module named 'stable_baselines3'

I'm trying to learn reinforcement learning, doing coding on Jupyter notebook. But when I try to install stable baselines I'm getting an error even though I've installed it and upgraded it several times. I'm attaching the screenshots as well. Appreciate any help.enter image description here

enter image description here

like image 922
Anandakrishnan Avatar asked Aug 31 '25 18:08

Anandakrishnan


2 Answers

I have just changed my answer, after talking to you I realised you have not installed in on your local computer.

If you are going to use jupyter.org's jupyter notebook, there is a better option. Jupyter.org's notebook doesn't have the best support for third party modules like this. It's just meant for testing small snippets of code. It probably doesn't have all the other requirements for running stable-baselines3 because it might be running on a minimal server environment. It's not meant for heavy usage like what you are suggesting.

Go to this website, https://colab.research.google.com and login using your google / gmail account. It's completely free.

Create a new notebook.

Type this in the cell and run it.

!pip install stable-baselines3[extra]

Next type this in another cell and run it.

import stable_baselines3

It works completely fine for me here.

If you want to install jupyter notebook on you computer and run it locally, you can try this guide, https://jupyter.org/install

If you don't want to try any of the options I suggested in the comments, you can check out this notebook on kaggle, https://www.kaggle.com/scratchpad/notebook7bff89da55/edit you can use it for free for 15 minutes without signing in.

like image 188
anarchy Avatar answered Sep 02 '25 07:09

anarchy


I had the same problem.
In my case it's because of memory shortage.
I changed my docker environment's memory limit from 2gb to 8gb then this problem has been solved.

like image 45
Nobuhito Kurose Avatar answered Sep 02 '25 09:09

Nobuhito Kurose