Stable Baselines doesn't work with tensorflow

自古美人都是妖i 提交于 2020-07-10 06:54:29

问题


So I recently got back into machine learning, and decided to start the Kaggle course for "ConnectX" (https://www.kaggle.com/learn/intro-to-game-ai-and-reinforcement-learning). I am trying to do lesson 4, in which I use stable-baselines + Tensorflow to make an AI. The problem is, I can't seem to use stable-baselines properly as it gives me an error instantly as I try to import it. Here is the error message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-13-f5986851ce81> in <module>
      1 import os
----> 2 from stable_baselines.bench import Monitor
      3 from stable_baselines.common.vec_env import DummyVecEnv
      4 
      5 # Create directory for logging training information

~\Anaconda3\lib\site-packages\stable_baselines\__init__.py in <module>
----> 1 from stable_baselines.a2c import A2C
      2 from stable_baselines.acer import ACER
      3 from stable_baselines.acktr import ACKTR
      4 from stable_baselines.deepq import DQN
      5 from stable_baselines.her import HER

~\Anaconda3\lib\site-packages\stable_baselines\a2c\__init__.py in <module>
----> 1 from stable_baselines.a2c.a2c import A2C

~\Anaconda3\lib\site-packages\stable_baselines\a2c\a2c.py in <module>
      5 import tensorflow as tf
      6 
----> 7 from stable_baselines import logger
      8 from stable_baselines.common import explained_variance, tf_util, ActorCriticRLModel, SetVerbosity, TensorboardWriter
      9 from stable_baselines.common.policies import ActorCriticPolicy, RecurrentActorCriticPolicy

~\Anaconda3\lib\site-packages\stable_baselines\logger.py in <module>
     15 from tensorflow.python.util import compat
     16 
---> 17 from stable_baselines.common.misc_util import mpi_rank_or_zero
     18 
     19 DEBUG = 10

~\Anaconda3\lib\site-packages\stable_baselines\common\__init__.py in <module>
      2 from stable_baselines.common.console_util import fmt_row, fmt_item, colorize
      3 from stable_baselines.common.dataset import Dataset
----> 4 from stable_baselines.common.math_util import discount, discount_with_boundaries, explained_variance, \
      5     explained_variance_2d, flatten_arrays, unflatten_vector
      6 from stable_baselines.common.misc_util import zipsame, set_global_seeds, boolean_flag

~\Anaconda3\lib\site-packages\stable_baselines\common\math_util.py in <module>
      1 import numpy as np
----> 2 import scipy.signal
      3 
      4 
      5 def safe_mean(arr):

~\Anaconda3\lib\site-packages\scipy\signal\__init__.py in <module>
    287 
    288 """
--> 289 from . import sigtools, windows
    290 from .waveforms import *
    291 from ._max_len_seq import max_len_seq

~\Anaconda3\lib\site-packages\scipy\signal\windows\__init__.py in <module>
     39 """
     40 
---> 41 from .windows import *
     42 
     43 __all__ = ['boxcar', 'triang', 'parzen', 'bohman', 'blackman', 'nuttall',

~\Anaconda3\lib\site-packages\scipy\signal\windows\windows.py in <module>
      5 
      6 import numpy as np
----> 7 from scipy import linalg, special, fft as sp_fft
      8 
      9 __all__ = ['boxcar', 'triang', 'parzen', 'bohman', 'blackman', 'nuttall',

~\Anaconda3\lib\site-packages\scipy\special\__init__.py in <module>
    631 from .sf_error import SpecialFunctionWarning, SpecialFunctionError
    632 
--> 633 from . import _ufuncs
    634 from ._ufuncs import *
    635 

ImportError: DLL load failed: The specified module could not be found.

It looks like something's wrong with scipy, but I have no idea what I can do to fix it. This error happens even if I run import stable_baselines. Here is the code I run to create the virtual environment (BTW, this is in PowerShell b/c that is what Jupyter Lab gives me):

python -m venv myenv
.\myenv\Scripts\Activate.ps1
pip install stable-baselines

NOTE: I don't know if this is of any significance, but when I install stable-baselines, an error appears: ERROR: gym 0.17.2 has requirement cloudpickle<1.4.0,>=1.2.0, but you'll have cloudpickle 1.5.0 which is incompatible.

PS: I found the same issue here, but I have no idea how they fixed it. The answer just says "I used anaconda", but there is no stable-baselines package in anaconda! I tried installing tensorflow from anaconda and stable-baselines from pip, but it still gave the same error.

LAST EDIT: Looks like this issue is on . imports and is only valid in jupyter notebook (doesn't have anything to do with tensorflow - it works fine in Python CLI). I have explained it in my new question about opencv here.

~ Ayush

来源:https://stackoverflow.com/questions/62735623/stable-baselines-doesnt-work-with-tensorflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!