首页 > 解决方案 > 如何将 Numpy 版本 1.19.5 与 Tensorflow 一起使用并且不会出现 numpy.ndarray 大小更改错误?

问题描述

我一直在尝试在我的新 m1 芯片计算机上使用 stable_baselines;但是,从我找到的一些示例代码中安装所有软件包后,我一直收到此错误

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

我知道这是在 numpy >= 1.20 中修复的;但是 tensorflow 需要 1.19.5;关于解决方法的任何建议?

这是完整的错误日志:

File "/opt/homebrew/lib/python3.9/site-packages/stable_baselines/__init__.py", line 4, in <module>
 from stable_baselines.a2c import A2C
File "/opt/homebrew/lib/python3.9/site-packages/stable_baselines/a2c/__init__.py", line 1, in <module>
 from stable_baselines.a2c.a2c import A2C
File "/opt/homebrew/lib/python3.9/site-packages/stable_baselines/a2c/a2c.py", line 5, in <module>
 import tensorflow as tf
File "/opt/homebrew/lib/python3.9/site-packages/tensorflow/__init__.py", line 41, in <module>
 from tensorflow.python.tools import module_util as _module_util
File "/opt/homebrew/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 48, in <module>
 from tensorflow.python import keras
File "/opt/homebrew/lib/python3.9/site-packages/tensorflow/python/keras/__init__.py", line 25, in <module>
 from tensorflow.python.keras import models
File "/opt/homebrew/lib/python3.9/site-packages/tensorflow/python/keras/models.py", line 22, in <module>
 from tensorflow.python.keras.engine import functional
File "/opt/homebrew/lib/python3.9/site-packages/tensorflow/python/keras/engine/functional.py", line 32, in <module>
 from tensorflow.python.keras.engine import training as training_lib
File "/opt/homebrew/lib/python3.9/site-packages/tensorflow/python/keras/engine/training.py", line 50, in <module>
 from tensorflow.python.keras.saving import hdf5_format
File "/opt/homebrew/lib/python3.9/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 37, in <module>
 import h5py
File "/Users/josephnordling/venv/lib/python3.9/site-packages/h5py/__init__.py", line 25, in <module>
 from . import _errors
File "h5py/_errors.pyx", line 1, in init h5py._errors
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

标签: pythonpython-3.xnumpytensorflowstable-baselines

解决方案


推荐阅读