【问题标题】:Issues installing Tensorflow on mac在 Mac 上安装 Tensorflow 的问题
【发布时间】:2019-01-07 01:40:14
【问题描述】:

我按照 tensorflow 网站的说明使用 virtualenv 进行安装,在 python 交互式 shell 中使用 import tensorflow as tf 验证安装时遇到以下问题。 请注意,我正在运行 Python 3.7

这是我已安装的软件包列表。

有人可以帮忙吗?

我还尝试使用pip uninstall protobuf 删除stackoverflow issue 建议的protobuf,但没有帮助。

【问题讨论】:

  • 您是否尝试过pip3 uninstall protobuf、brew uninstall protobuf 并重新安装 TensorFlow?
  • 是的,已尝试多次卸载 protobuf 和 tensorflow,但没有成功。默认情况下,我安装 tensorflow 时会安装 protobuf。 pip3 install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.9.0-py3-none-any.whl

标签: macos tensorflow


【解决方案1】:

经过一番研究,我能够解决上述问题。看起来,tensorflow 与我在计算机上安装的 python 3.7(截至 18 年 7 月 30 日)不兼容。 关注github issue 帮助我解决了这个问题。

我使用 pyenv 安装了 python 3.6.6 并设置了 virtualenv。这是我所做的:

# Install python 3.3.6 and create virtualenv    
$ pyenv install 3.6.6
    $ pyenv virtualenv 3.6.6 tensorflow_image_recognition_3_6_6
    $ pyenv activate tensorflow_image_recognition_3_6_6

# update pip
    $ easy_install -U pip

#Install tensorflow
    $ pip3 install --upgrade tensorflow

# Test if tensorflow is installed properly
    # open python interactive shell
    $ python 
    import tensorflow as tf
    hello = tf.constant('Hello, TensorFlow!')
    sess = tf.Session()
    print(sess.run(hello))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-28
    • 2021-05-17
    • 2018-07-14
    • 1970-01-01
    相关资源
    最近更新 更多