我在Apple MacBook Air M1上使用PyCharme来学习TensorFlow的基础知识。我使用Anaconda创建了开发环境,详细信息如下:
- Python 3.9.15
- tensorflow -Macos 2.11.0
- tensorflow -金属0.7.0
- 麻木1.21.5
我在代码中导入了tensorflow,如下所示:
import os
import tensorflow as tf
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
当在我的"training_loop www.example.com"文件中运行此代码时,我收到如下运行时错误:final.py" file , Im getting runtime error as below:
/Users/kapo/opt/anaconda3/envs/env_tf/bin/python /Users/kapo/PycharmProjects/tensorflow-course/03/training_loop final.py
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
Traceback (most recent call last):
File "/Users/kapo/PycharmProjects/tensorflow-course/03/training_loop final.py", line 2, in <module>
import tensorflow as tf
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 42, in <module>
from tensorflow.python import data
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/data/__init__.py", line 21, in <module>
from tensorflow.python.data import experimental
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/data/experimental/__init__.py", line 96, in <module>
from tensorflow.python.data.experimental import service
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/data/experimental/service/__init__.py", line 419, in <module>
from tensorflow.python.data.experimental.ops.data_service_ops import distribute
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 22, in <module>
from tensorflow.python.data.experimental.ops import compression_ops
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py", line 16, in <module>
from tensorflow.python.data.util import structure
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/data/util/structure.py", line 22, in <module>
from tensorflow.python.data.util import nest
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/data/util/nest.py", line 34, in <module>
from tensorflow.python.framework import sparse_tensor as _sparse_tensor
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/framework/sparse_tensor.py", line 24, in <module>
from tensorflow.python.framework import constant_op
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/framework/constant_op.py", line 25, in <module>
from tensorflow.python.eager import execute
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/eager/execute.py", line 21, in <module>
from tensorflow.python.framework import dtypes
File "/Users/kapo/opt/anaconda3/envs/env_tf/lib/python3.9/site-packages/tensorflow/python/framework/dtypes.py", line 34, in <module>
_np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type()
TypeError: Unable to convert function return value to a Python type! The signature was
() -> handle
Process finished with exit code 1
有人知道我如何解决这个问题吗?它的意思是"模块编译API版本0x10,但这个版本的numpy是0xf"
1条答案
按热度按时间lc8prwob1#
tensorflow-macos 2.11.0将不会在您当前的环境中运行。
您需要将python升级到3.10才能运行tensorflow-macos 2.10.0,将python升级到3.11才能运行tensorflow-macos 2.11.0
在numpy中还缺少一个依赖项,因此最好至少将其升级到1.23.4。