所以我最近重新开始学习机器学习,并决定开始“ConnectX”的 Kaggle 课程(https://www.kaggle.com/learn/intro-to-game-ai-and-reinforcement-learning)。我正在尝试做第 4 课,其中我使用稳定基线 + TensorFlow 来制作 AI。问题是,我似乎无法正确使用稳定基线,因为当我尝试导入它时它会立即给我一个错误。这是错误消息:
---------------------------------------------------------------------------
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.
看起来有问题scipy
,但我不知道我能做些什么来解决它。即使我运行此错误也会发生import stable_baselines
。这是我为创建虚拟环境而运行的代码(顺便说一句,这是在 PowerShell b/c 中,这是 Jupyter Lab 给我的):
python -m venv myenv
.\myenv\Scripts\Activate.ps1
pip install stable-baselines
注意:我不知道这是否有任何意义,但是当我安装时stable-baselines
,会出现错误: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:我在这里发现了同样的问题,但我不知道他们是如何解决的。答案只是说“我用过 anaconda”,但 anaconda 中没有stable-baselines
包!我尝试从 anaconda 安装 tensorflow 并从 pip 安装 stable-baselines,但它仍然给出了同样的错误。
最后编辑:看起来这个问题是关于.
导入的,并且仅在jupyter notebook
(与它没有任何关系tensorflow
- 它在 Python CLI 中工作正常)有效。我已经在关于opencv
这里的新问题中解释了它。
〜阿尤什