【问题标题】:tensorflow installation(both 1.5.0 and 1.6.0) doesn't work on mac osx yosemitetensorflow 安装(1.5.0 和 1.6.0)在 mac osx yosemite 上不起作用
【发布时间】:2018-08-11 22:54:34
【问题描述】:

1.5.0 安装正常,但是当我导入 tensorflow 时,我得到这个错误:

RuntimeError: module compiled against API version 0xa but this version
of numpy is 0x9 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
"/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 24,
in <module>
    from tensorflow.python import *   File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py",
line 63, in <module>
    from tensorflow.python.framework.framework_lib import *   File "/Library/Python/2.7/site-packages/tensorflow/python/framework/framework_lib.py",
line 81, in <module>
    from tensorflow.python.framework.sparse_tensor import SparseTensor   File
"/Library/Python/2.7/site-packages/tensorflow/python/framework/sparse_tensor.py",
line 25, in <module>
    from tensorflow.python.framework import tensor_util   File "/Library/Python/2.7/site-packages/tensorflow/python/framework/tensor_util.py",
line 34, in <module>
    from tensorflow.python.framework import fast_tensor_util   File "__init__.pxd", line 163, in init
tensorflow.python.framework.fast_tensor_util ValueError: numpy.dtype
has the wrong size, try recompiling. Expected 88, got 96

1.6.0 安装失败,出现以下错误:

DEPENDENCY ERROR

The target you are trying to run requires an OpenSSL implementation.
Your system doesn't have one, and either the third_party directory
doesn't have it, or your compiler can't build BoringSSL.

Please consult INSTALL to get more information.

If you need information about why these tests failed, run:

  make run_dep_checks


make: Circular /private/tmp/pip-build-Lth8PD/grpcio/libs/opt/libares.a <- /private/tmp/pip-build-Lth8PD/grpcio/libs/opt/libz.a dependency dropped.
make: *** [stop] Error 1

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-build-Lth8PD/grpcio/setup.py", line 311, in <module>
    cmdclass=COMMAND_CLASS,
  File "/Library/Python/2.7/site-packages/setuptools/__init__.py", line 129, in setup
    return distutils.core.setup(**attrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Library/Python/2.7/site-packages/setuptools/command/install.py", line 61, in run
    return orig.install.run(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
    self.run_command('build')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Library/Python/2.7/site-packages/setuptools/command/build_ext.py", line 78, in run
    _build_ext.run(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run
    self.build_extensions()
  File "/private/tmp/pip-build-Lth8PD/grpcio/src/python/grpcio/commands.py", line 278, in build_extensions
    raise Exception("make command failed!")
Exception: make command failed!

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, 
tokenize;__file__='/private/tmp/pip-build-Lth8PD/grpcio/setup.py';f=getattr(tokenize, 'open', open) 
(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, 
__file__, 'exec'))" install --record /tmp/pip-eSD2il-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-Lth8PD/grpcio/

【问题讨论】:

  • 看起来您正在尝试安装 Tensorflow 以使用 OSX 系统 Python。 Installation instructions 推荐使用某种类型的 virtualenv。我总是按照官方说明使用 conda 在 Mac 上安装 TF,从来没有遇到任何问题。

标签: python-2.7 numpy tensorflow


【解决方案1】:

我遇到了同样的问题。安装报错是因为新版本的tensorflow需要新的依赖(grpcio)。以下是我处理问题的方法。

强制安装二元轮。

$ pip install --no-cache-dir --only-binary :all: grpcio==1.10.1

然后我可以升级我的 tensorflow。

$ pip install --upgrade tensorflow      # for Python 2.7
$ pip3 install --upgrade tensorflow     # for Python 3.n

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-24
    • 2015-06-15
    • 2015-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多