mac电脑重装tensorflow遇到的一个坑

sudo pip install tensorflow出现问题:

c++: error: unrecognized command line option '-stdlib=libc++'
    make: *** [/private/tmp/pip-install-XdJ7yo/grpcio/objs/opt/third_party/boringssl/ssl/bio_ssl.o] Error 1
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-XdJ7yo/grpcio/setup.py", line 348, in <module>
        cmdclass=COMMAND_CLASS,
      File "/usr/local/lib/python2.7/site-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 563, in run
        self.run_command('build')
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python2.7/site-packages/setuptools/command/build_ext.py", line 75, in run
        _build_ext.run(self)
      File "/usr/local/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
        _build_ext.build_ext.run(self)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/private/tmp/pip-install-XdJ7yo/grpcio/src/python/grpcio/commands.py", line 287, in build_extensions
        raise Exception("make command failed!")
    Exception: make command failed!
    
    ----------------------------------------
  Rolling back uninstall of grpcio
Command "/usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-XdJ7yo/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 /private/tmp/pip-record-zx8SD3/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-install-XdJ7yo/grpcio/

在stackoverflow上看到这个解释:

https://stackoverflow.com/questions/24419832/unrecognized-command-line-option-stdlib-libc-with-macports-gcc48

-stdlib=libc++ is a Clang (not GCC) option and tells clang to use LLVM libc++ standard library (which is what Clang uses) rather than GNU libstdc++ (which is what GCC uses).

mac电脑测试了下gcc和clang版本:

gcc --version

gcc (MacPorts gcc5 5.4.0_2) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin15/5.4.0/lto-wrapper
Target: x86_64-apple-darwin15
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc5/gcc5/work/gcc-5.4.0/configure --prefix=/opt/local --build=x86_64-apple-darwin15 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc5 --includedir=/opt/local/include/gcc5 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-5 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-5 --with-gxx-include-dir=/opt/local/include/gcc5/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-tls --with-pkgversion='MacPorts gcc5 5.4.0_2'

clang -v

Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

解决:

重新安装gcc:

brew install gcc,未解决。

重新安装LLVM/Clang:

参照installing-clangllvm-on-osx
先查看下llvm:
brew info llvm

llvm: stable 6.0.1 (bottled), devel 7.0.0rc3, HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/llvm.rb
==> Dependencies
Build: cmake ✘
Required: libffi ✘
Optional: python@2 ✘
==> Options
--with-lldb
        Build LLDB debugger
--with-python@2
        Build bindings against Homebrew's Python 2
--with-toolchain
        Build with Toolchain to facilitate overriding system compiler
--devel
        Install development version 7.0.0rc3
--HEAD
        Install HEAD version
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

看信息llvm好像Not installed,安装下:brew install llvm
安装到一半停掉了,怕cause all kinds of trouble

卸载gcc:未解决

排查clang

hellloworld.c 测试clang有没问题,没问题。

重装grpcio:

因为是在grpcio安装时报错
发现一个类似的错误:
https://github.com/tensorflow/tensorflow/issues/17369

1.10.0有错误,试试降低版本:sudo pip install grpcio==1.9.1

worked for me!!!!!!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值