我刚把我的numpy从1.19更新到1.24。但这似乎会在导入tensorflow时导致错误。import tensorflow as tf
生成以下AttributeError
。下面是对错误的追溯。我正在使用Python 3.8,TensorFlow 2.6.0和Numpy 1.24(从1.19更新)。当我使用numpy 1.19时,代码运行得很好。但是将numpy更新到1.24似乎会导致这个错误。任何想法和/或解决此冲突。
import tensorflow as tf
Traceback (most recent call last):
Cell In[7], line 1
import tensorflow as tf
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/__init__.py:41
from tensorflow.python.tools import module_util as _module_util
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/__init__.py:46
from tensorflow.python import data
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/data/__init__.py:25
from tensorflow.python.data import experimental
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/data/experimental/__init__.py:97
from tensorflow.python.data.experimental import service
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/data/experimental/service/__init__.py:353
from tensorflow.python.data.experimental.ops.data_service_ops import distribute
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py:26
from tensorflow.python.data.experimental.ops import compression_ops
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py:20
from tensorflow.python.data.util import structure
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/data/util/structure.py:26
from tensorflow.python.data.util import nest
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/data/util/nest.py:40
from tensorflow.python.framework import sparse_tensor as _sparse_tensor
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/framework/sparse_tensor.py:28
from tensorflow.python.framework import constant_op
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py:29
from tensorflow.python.eager import execute
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/eager/execute.py:27
from tensorflow.python.framework import dtypes
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/tensorflow/python/framework/dtypes.py:585
np.object,
File ~/opt/anaconda3/envs/profiler/lib/python3.8/site-packages/numpy/__init__.py:305 in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'object'.
`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
如有任何帮助,我们将不胜感激。谢谢.
1条答案
按热度按时间v6ylcynt1#
将tensorflow升级到2.13似乎已经缓解了这个问题。