我现在正在研究Ubuntu试图解决这个问题。我试图让Pyglet在.py脚本中工作。 所以,我在Ubuntu上使用默认的Python安装(2.7.3,Ubuntu v = 12.4)。我用了: sudo apt-get install python-pyglet 这个运行正常。当我打开终端时,输入'python'并运行
import pyglet
import pyglet.window
它有效。但是,当我在.py中有这两个相同的单词时,在终端中运行它(通过'python'路径到.py“'我得到:
File "/home/parallels/Documents/Google/computer-vision/pyglet.py", line 3, in <module>
import pyglet
File "/home/parallels/Documents/Google/computer-vision/pyglet.py", line 4, in <module>
import pyglet.window
ImportError: No module named window
我的PYTHONPATH(在python中显示,输入sys.path是:
['', '/usr/lib/pymodules/python2.7', '/home/parallels', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
有没有人知道库/装置出了什么问题才能使它不起作用?
萨姆
答案 0 :(得分:4)
您的模块名为pyglet.py
。因此,import
语句在您自己的模块中查找子模块window
,当然无法找到它。更改脚本的文件名,然后重试。