No module named 'stable_baseline3' even when it is installed in google colab - google-colaboratory

I am trying to set up stable baselines 3 in google colab. The document is connected to a local runtime on my pc through jupyter notebooks. On my pc i have installed stable baselines 3 using anaconda, and got the output saying essentially stable baselines 3 is installed. I have also run the cells:
!pip install stable-baselines3[extra]
!pip install stable-baselines3
and
!pip install stable-baselines3 --upgrade
Despite this, when i run the cell:
import stable_baseline3
from stable_baselines3 import DQN
etc...
I get the error on line 1 of ModuleNotFoundError: No module named 'stable_baseline3'. I dont understand why this would be happening, does anybody know how it could be solved?

i had the same problem
try to import stable-baselines3 first in alone cell and it should work
!pip install stable-baselines3

Related

Can't import pytorch_lightning on Google colab

I'm using !pip install git+https://github.com/PyTorchLightning/pytorch-lightning
but when I'm importing pytorch_lightning I get the following error:
ImportError: cannot import name '_RequirementAvailable' from 'pytorch_lightning.utilities.imports' (/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py)
It all worked fine a week ago...
When you install Lightning as
pip install git+https://github.com/PyTorchLightning/pytorch-lightning
you get the latest version in development. It is not an official release. I recommend installing
pip install pytorch-lightning
to get the latest stable release. I suspect this will solve your import error.

How to install tensorflow in win 10

The tensorflow is installed by using "conda install tensorflow". by importing tensorflow with "import tensorflow" in spyder in same environment which tensorflow was installed, it give an error "ModuleNotFoundError: No module named 'tensorflow'".
For every one who is faced with this problem i suggest to check if they have already installed spyder in desired environment with "conda install spyder". I installed it and the problem fixed

Jupyter Notebook import not working after recent update

I recently used the following command to update my jupyter packages conda update --all and from then on my visualization libraries wont import(matplotlib and seaborn). I used conda install <pkg> even then it wouldnt. So I reinstalled anaconda3 but same problem persists...
I tried to view sys.executable and found that it was not referencing my python lib in anaconda but in python click here
'c:\\python38\\python.exe' So i used pip3 install matplotlib and matplotlib worked. I want my jupyter to reference to its own lib stack as I cannot install all libraries in python. I want the jupyter to read packages from this path : C:\Users\princ\anaconda3\Lib\site-packages because all anaconda libraries are there. How do I do it? Help me please. The problem is jupyter is referencing python package folder and not pre installed packages in anaconda
SYS.PATH:
'c:\\python38\\python38.zip',
'c:\\python38\\DLLs',
'c:\\python38\\lib',
'c:\\python38',
'',
'C:\\Users\\princ\\AppData\\Roaming\\Python\\Python38\\site-packages',
'c:\\python38\\lib\\site-packages',
'c:\\python38\\lib\\site-packages\\win32',
'c:\\python38\\lib\\site-packages\\win32\\lib',
'c:\\python38\\lib\\site-packages\\Pythonwin',
'c:\\python38\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\princ\\.ipython']
jupyter kernelspec list
python3 c:\python38\share\jupyter\kernels\python3
Did you tried running pip using directly the python executable with
python.exe -m pip install <pkg>
I don't know if there is a similar way to do it with conda

tensorflow on crestle with python 3.7

I am using crestle.ai site to build some models. In the Jupyter notebook when I try to import something from keras I get :
****ModuleNotFoundError: No module named 'tensorflow'****
I found that tensorflow does not work with Python 3.7 which is pre-installed in crestle. So I tried several ways to install Python 3.5 but nothing worked
!conda install python=3.5.0 --yes
I got:
Solving environment: failed UnsatisfiableError: The following specifications were found to be in conflict:
- jupyter_contrib_nbextensions -> jupyter_highlight_selected_word[version='>=0.1.1'] ->
python[version='>=3.7,<3.8.0a0'] -> readline[version='>=7.0,<8.0a0']
- jupyter_contrib_nbextensions -> jupyter_highlight_selected_word[version='>=0.1.1'] ->
python[version='>=3.7,<3.8.0a0'] -> tk[version='>=8.6.8,<8.7.0a0']
- jupyter_contrib_nbextensions -> jupyter_highlight_selected_word[version='>=0.1.1'] ->
python[version='>=3.7,<3.8.0a0'] -> xz[version='>=5.2.4,<6.0a0']
- python=3.5.0 Use "conda info " to see the dependencies for each package.
!pip3 install --upgrade tensorflow-gpu
I got
Collecting tensorflow-gpu Could not find a version that satisfies
the requirement tensorflow-gpu (from versions: ) No matching
distribution found for tensorflow-gpu
!pip install --upgrade tensorflow
I got:
Collecting tensorflow Could not find a version that satisfies the
requirement tensorflow (from versions: ) No matching distribution
found for tensorflow
I am following suggestions from different blogs and don't know what I am doing or if I am doing it right.
As per Anand's suggestion
!conda env list
​
**# conda environments:
#
base /home/nbuser/.anaconda3
new_environment /home/nbuser/.anaconda3/envs/new_environment
py36 /home/nbuser/.anaconda3/envs/py36
tensorflow /home/nbuser/.anaconda3/envs/tensorflow**
!source activate py36
/bin/sh: 1: source: not found
Do I need some path command?
Edit:
!activate py36
I got no output!
!pip3 install --upgrade tensorflow
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
enter image description here
enter image description here
Edit:
Thanks. I was not aware of the terminal and was doing it wrong!
This is what I got after $pip install tensorflow-gpu
after pip command
What do I need to do next? I tried in Jupyter importing modules from keras but again I got:
Using TensorFlow backend.
ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 from keras.models import Sequential
I also tried to use keras on crestle.com instead (previous was crestle.ai). I got this:
keras on crestle.com
It shows python 3.6 but the similar issue..
python[version='>=3.7,<3.8.0a0'] This is part of your error, this basically means that you are still unable to get out of using Python3.7, hence the no module found error, I would suggest you to make a new environment in conda using.
conda create --name py36 python=3.6
In your conda prompt, then activate this environment by using
After that use conda env list and you should see an Enviornment named py36.
Activate this environment by using source activate py36
Edit If you are using conda prompt not terminal, directly use activate py36
Then try pip commands again, once the environment is activated.
If it still fails, let me know and we will see what the problem might be.
Edit You have to use this commands in the terminal that comes with crestle and not in its's Jupyter notebook.
The terminal can be accessed from the top right, you can see the New_>Terminal Button. And if it says conda is not installed, you might follow this link. https://www.digitalocean.com/community/tutorials/how-to-install-the-anaconda-python-distribution-on-ubuntu-16-04

ipython cannot search matplotlib while using tensorflow and jupyter also has import error

I am using python 2.7 in Ubuntu and recently updated tensorflow 0.12.1.
I installed jupyter today for my sample code of tf and I need to use matplotlib. It does not find module name matplotlib and ipython in tensorflow has same error.
1. How can I set path in virtualenv or ipython or jupyter?
After activate tensorflow, I need to use jupyter notebook.
This below in the script for error does not work.
import sys
sys.path.append('my/path/to/module/folder')
import module-of-interest
2. other information: My environments are below.
mickyefromsd#DEKSTOP~$source ~/tensorflow/bin/activate
When I find matplotlib by python script under TF condition and before TF activation, it has below;
/usr/lib/python2.7/dist-packages/matplotlib/
When I type 'which ipython', it has below (not by /usr/bin/ipython) ;
/home/mickeyfromd/tensorflow/bin/ipython
Btw, /tensorflow/lib/python2.7/site-packages/ it has ipython and jupyter.
(not in the same path of matplotlib)
3. My ipython under TF cannot find my existing matplotlib.
(tensorflow) mickeyfromd#DK-DESKTOP:~$ ipython
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
In [1]: import matplotlib ImportError: No module named matplotlib
4. I wanted to setup virtualenv, so I just run this
I followed this site. site:http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs
(tensorflow) mickeyfromd#ipython kernelspec install-self --user
.....
Installed kernelspec python2 in /home/mickeyfromd/.local/share/jupyter/kernels/python2
(tensorflow) mickeyfromd#DK-DESKTOP:~$
I cannot move the the folder (in the second step)
How can I make ipython to have path for Matplotlib?
That import error is due to change in environment of the jupyter notebook. You might have installed the packages in one environment and you are running the jupyter notebook in another environment.
I have got two environments (envs) in my Anaconda folder ( I have Anaconda3 folder to be specific ).
(windows key+cmd ) -> open the windows command prompt run as administrator.
Activate (name of the environment) -> eg.: activate tensorflow-gpu
Start installing packages using conda install
Note: For each environment you need to install all the packages you want to use, separately using the same process. This solution is for windows users, might work for linux users not sure though.
Additionally to make sure your conda environment is up to date run:
conda update conda
conda update anaconda
check this out : https://pradyumnamajumder.wordpress.com/2017/09/30/solution-to-the-python-packages-import-error-in-jupyter/