Question

I'm now working on Ubuntu to try and solve this. I am trying to get Pyglet to work in a .py script. So, I am using the default install of Python on Ubuntu (2.7.3, Ubuntu v = 12.4). I used: sudo apt-get install python-pyglet and this ran ok. When I open a terminal, enter 'python' and run

import pyglet
import pyglet.window

it works. However, when I have these same two words in a .py, and run that in terminal (by going 'python "path to .py"' I get:

  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

My PYTHONPATH (shown by, in python, entering sys.path is:

['', '/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']

Does anybody have any idea what is going wrong with the library / installation to make it not work?

Sam

Was it helpful?

Solution

Your module is named pyglet.py. Because of that, the import statement looks in your own module for the submodule window, where of course it cannot be found. Change the file name of your script and try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top