2016-07-24 120 views
0

我必須使用packages tensorflow和pygame。奇怪的行爲:相同的代碼,不同的錯誤

在我的機器[Ubuntu 15.04] [Anaconda,Python = 2.7]中,我在相同的環境中安裝了 pygame和tensorflow。

現在,當我輸入tensorflow在Python解釋:

>>> 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: [email protected] 
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 

回答

0

你有沒有以正確的方式安裝的蟒蛇?

$ 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並確保它處於正確的路徑。

+0

plz在最後看到有問題的更新。 –

+0

不幸的是,找不到任何目錄問題。 –

0

嘗試$ sudo pip install tensorflow

相關問題