gpt4 book ai didi

python - 导入tensorflow时出现numpy版本错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:22:35 24 4
gpt4 key购买 nike

我已经为 tensorflow 执行了 pip install

python命令行环境下,当我试过

import tensorflow as tf

我遇到了以下错误:

RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

我已经使用 print numpy.__version__ 检查了我的 numpy 版本。它显示 “1.8.2”。那么,我现在该怎么办?谢谢!

最佳答案

从错误来看,您似乎正在从 usr/local/bin 运行 python 2.7。您的 numpy 版本与 tensorflow 安装之间存在不匹配问题。我建议您安装 anaconda,因为它将确保安装与您的 numpy 版本兼容的正确版本的 tensorflow

一旦你有了 anaconda,然后做:

conda install -c conda-forge tensorflow

关于python - 导入tensorflow时出现numpy版本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39908504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com