【问题标题】:Strange behaviour: Same code, different errors奇怪的行为:相同的代码,不同的错误
【发布时间】:2016-07-24 10:25:30
【问题描述】:

我必须使用包 tensorflow 和 pygame。

在我的机器 [Ubuntu 15.04][Anaconda, Python=2.7] 我安装了 pygame和tensorflow在同一个环境中。

现在,当我在 Python 解释器中导入 tensorflow 时:

>>> import tensorflow

它工作正常。如果我通过/usr/bin/python进入解释器

然后做>>> import tensorflow 我明白了:

Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named tensorflow

除此之外,每次在/usr/bin/python

运行程序后,我得到:

>>> execfile("deep_q_network.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "deep_q_network.py", line 4, in <module>
    import tensorflow as tf
ImportError: No module named tensorflow

并且在python解释器中运行相同的程序,我得到:

>>> execfile("deep_q_network.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "deep_q_network.py", line 8, in <module>
    import wrapped_flappy_bird as game
  File "game/wrapped_flappy_bird.py", line 19, in <module>
    IMAGES, SOUNDS, HITMASKS = flappy_bird_utils.load()
  File "game/flappy_bird_utils.py", line 21, in load
    pygame.image.load('assets/sprites/0.png').convert_alpha(),
pygame.error: File is not a Windows BMP file

尽管花费了数小时来安装和修复这些安装,但我的代码似乎还是失败了。

请帮忙解决一下。


pip show tensorflow 给出:

---
Metadata-Version: 2.0
Name: tensorflow
Version: 0.9.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
Installer: pip
License: Apache 2.0
Location: /home/v/anaconda2/envs/tensorflow/lib/python2.7/site-packages
Requires: numpy, six, protobuf, wheel
Classifiers:
  Development Status :: 4 - Beta
  Intended Audience :: Developers
  Intended Audience :: Education
  Intended Audience :: Science/Research
  License :: OSI Approved :: Apache Software License
  Programming Language :: Python :: 2.7
  Topic :: Scientific/Engineering :: Mathematics
  Topic :: Software Development :: Libraries :: Python Modules
  Topic :: Software Development :: Libraries
Entry-points:
  [console_scripts]
  tensorboard = tensorflow.tensorboard.tensorboard:main

【问题讨论】:

    标签: python python-2.7 pygame tensorflow development-environment


    【解决方案1】:

    您是否以正确的方式安装了 Anaconda?

    $ conda install virtualenv
    $ conda create --name=tensorflow_env python=2.7
    $ source activate tensorflow_env
    $ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
    

    也许,您也将它安装在错误的目录中。 尝试运行: pip show tensorflow 并确保它在正确的路径中。

    【讨论】:

    • 很遗憾,找不到任何目录问题。
    【解决方案2】:

    试试$ sudo pip install tensorflow

    【讨论】:

      猜你喜欢
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-25
      • 1970-01-01
      • 2017-09-13
      • 2017-01-04
      • 1970-01-01
      相关资源
      最近更新 更多