gpt4 book ai didi

python - Tensorflow 没有正确安装

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

我是初学者,我尝试根据网站上的说明在 Macbook 上安装 tensorflow 。

sudo easy_install pip
sudo easy_install --upgrade six
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl

安装后,当我尝试导入 tensorflow 时,出现以下错误:

    >>> import tensorflow
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 50, in <module>
from tensorflow.python.framework.framework_lib import *
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/framework_lib.py", line 62, in <module>
from tensorflow.python.framework.ops import Graph
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 40, in <module>
from tensorflow.python.framework import versions
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/versions.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/Library/Python/2.7/site-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
>>>

我是 python 的新手,我在互联网上尝试了一些解决方案,但到目前为止都没有奏效。错误可能是由于 pip 安装引起的。自 2 天以来,我一直坚持这一点。感谢您的帮助!

最佳答案

为了补充上一个答案 - 在我的 OSX 机器 (10.11) 上,我发现了两个工厂安装的 numpy - 一个在 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy 和另一个在 /Library/Python/2.7/site-packages/numpy/。据我所知,pip 将升级/Library 中的那个,但 python 一直尝试首先使用/System/Library/中的那个。

作为临时解决方案,我只是将/System/Library 中的numpy 文件夹重命名为numpy.oldTensorflow 之后正确导入。

关于python - Tensorflow 没有正确安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34750543/

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