0

I'm trying to import A2C from stable_baselines using the following code line:

from stable_baselines import A2C

But I get the following error:

ModuleNotFoundError: No module named 'tensorflow.contrib'

I tried installing an old version of Tensorflow using the following command:

pip install tensorflow==1.15.0

But I get the following error:

Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement tensorflow==1.15.0 (from versions: 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7.0rc0, 2.7.0rc1, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1)
ERROR: No matching distribution found for tensorflow==1.15.0

I tried installing Tensorflow 1.15.0 using the .whl file:

pip install tensorflow-1.15.0-cp37-cp37m-manylinux2010_x86_64.whl 

But I also get an error:

Defaulting to user installation because normal site-packages is not writeable
ERROR: tensorflow-1.15.0-cp37-cp37m-manylinux2010_x86_64.whl is not a supported wheel on this platform.

I tried upgrading pip and uninstalling Tensorflow but I still get the same errors.

How can I deal with this problem?

AidenFive
  • 29
  • 1
  • 7

1 Answers1

0

'tensorflow.contrib' is no longer supported and deprecated to use in Tensorflow 2.x and Stable-Baselines also supports only Tensorflow versions 1.x.

To avoid this error ModuleNotFoundError: No module named 'tensorflow.contrib', you need to install Tensorflow 1.x using the below code if you have python 3.5 to 3.7 installed in your system.

!pip install tensorflow==1.15
!pip install stable_baselines
from stable_baselines import A2C

or you can try by coverting the runtime to Tensorflow 1.x before executing stable_baselines code:

%tensorflow_version 1.x

However, Tensorflow 1 is deprecated, and support will be removed on August 1, 2022. So It is suggested to use stable_baselines3 in the place of stable_baselines in Tensorflow 2.x.

!pip install stable_baselines3
from stable_baselines3 import A2C