【问题标题】:Installing prettytensor for TensorFlow not working on OSX为 TensorFlow 安装 prettytensor 无法在 OSX 上运行
【发布时间】:2016-07-29 04:48:58
【问题描述】:

我无法安装prettytensor。我已经尝试通过pip 以及通过安装源代码并在目录中执行python setup.py install 来实现它。

我更新了我的 tensorflow 。有没有人知道如何在我的机器上安装prettytensor

pip install prettytensor
Requirement already satisfied (use --upgrade to upgrade): prettytensor in ./anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): enum34>=1.0.0 in ./anaconda/lib/python2.7/site-packages (from prettytensor)
Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in ./anaconda/lib/python2.7/site-packages (from prettytensor)
Collecting tensorflow>=0.7.1 (from prettytensor)
  Could not find a version that satisfies the requirement tensorflow>=0.7.1 (from prettytensor) (from versions: )
No matching distribution found for tensorflow>=0.7.1 (from prettytensor)

当我尝试导入 prettytensor

Python 2.7.11 |Anaconda 2.3.0 (x86_64)| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
>>> import prettytensor as pt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Mu/anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg/prettytensor/__init__.py", line 25, in <module>
    from prettytensor import funcs
  File "/Users/Mu/anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg/prettytensor/funcs.py", line 25, in <module>
    from prettytensor.pretty_tensor_image_methods import *
  File "/Users/Mu/anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg/prettytensor/pretty_tensor_image_methods.py", line 20, in <module>
    from prettytensor import layers
ImportError: cannot import name layers

【问题讨论】:

    标签: python installation pip tensorflow prettytensor


    【解决方案1】:

    请检查 tensorflow 的版本。

    如果你的 tensorflow 不是 0.7.1,你可以像下面这样升级。

    (另见https://www.tensorflow.org/versions/r0.7/get_started/os_setup.html

    # Mac OSX, CPU only:
    $ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp27-none-any.whl
    

    然后再次安装 prettytensor。

    $ pip uninstall prettytensor
    $ pip install prettytensor
    

    供您参考。 这是我的结果。(OSX 10.11.3)

    In [1]: import tensorflow as tf
    
    In [2]: tf.__version__
    Out[2]: '0.7.1'
    
    In [3]: import prettytensor as pt
    
    In [4]: pt.PrettyTensor
    Out[4]: prettytensor.pretty_tensor_class.PrettyTensor
    

    【讨论】:

    • 那行得通。起初我的 setuptools 出现错误,然后 protobuf 出现错误。您的帖子和github.com/tensorflow/tensorflow/issues/1244 的组合解决了这个问题。
    • 这对我不起作用,我不确定应该安装什么版本的prettytensor,我从这里使用tf 0.7.1 hub.docker.com/r/tensorflow/tensorflow/tags/… 我也尝试了不同的版本并且有可悲的是导入漂亮张量的不同问题。我正在尝试重现 OpenAI infogan 结果,但无法复制他们的系统配置...
    • 嗨@BrunoCL。您在导入 prettytensor 时看到了什么样的错误?当我尝试使用 tf-2.4.0-rc0 和 prettytensor-0.7.4 时,我得到了 AttributeError,因为有些键在 tensorflow-2.x 中已被弃用。因此我将import tensorflow as tf修改为import tensorflow.compat.v1 as tf; tf.disable_v2_behavior,这些错误都解决了。我希望这会有所帮助。
    猜你喜欢
    • 1970-01-01
    • 2015-05-24
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    • 2011-04-10
    • 1970-01-01
    • 2019-06-11
    • 2020-10-12
    相关资源
    最近更新 更多