Forums

pyglet issues

I successfully installed pyglet in my local folder (so 'import pyglet' works), but when I try to do 'import pyglet.gl' I get the following error: ImportError: Library "GLU" not found. Seems like some drivers issues though don't really know... Any ideas how to fix that? Thanks!

If I remember correctly, pyglet is a cross-platform GUI widget library, similar to wxPython. I don't see how this would be useful on a remote server environment like PythonAnywhere. In this context, GLU likely refers to the OpenGL Utility Library, and I'd be amazed and impressed if a hosted environment like PA found a way to support OpenGL.

What are you trying to achieve?

Thanks for your response.

I am, in fact, not using pyglet directly but via psychopy which I use to program experiments in our lab. So what I am trying to do here is to take text input from users, render the text as an image (using psychopy/pyglet), apply certain numpy.ndimage filters, and give the output the the user. It seems like one way or another I would need OpenGL to be supported in order to do this even if I could substitute pyglet for something else. Maybe PythonAnywhere just isn't the tool for that kind of a project?

What you're trying to do sounds very like the process used to generate CAPTCHAS, and that's something that can definitely be done by web services. Whether it's the most convenient way for you to do it is a more complicated question.

Certainly turning text into an image shouldn't need OpenGL, which is a general 2D/3D graphics library and is aimed more at real-time 3D graphics (e.g. games) than generating static images (I'm not saying it can't be used for static images, just that's not really its focus). I would suggest looking at PIL, the Python Imaging Library, as I'm pretty sure it has primitives for rendering text as a static image. It also has the advantage of being pre-installed on the PA environment, I believe.

What I'm not sure about is how easy it'll be to get an image from PIL into whatever format numpy.ndimage requires - I'm sure it must be possible to get it into plain bitmap data form, however.

Edit: Whether PA is the best place for you to do this stuff is really a question for you to answer yourself. As I say, it has pre-installed tools for dealing with images, but if they're not the ones with which you're familiar then you may burn quite a bit of time learning them. On the other hand, if you've got the time then it might be a useful way to expand your Python knowledge, if that's something that attracts you. Certainly PA makes it very convenient to host web applications which might be useful to you. If you need to do any real-time (i.e. animated) graphics then I'd strongly consider instead running scripts locally instead. Nothing to stop you using PA as a shared editing environment even then, especially as it makes integrating with things like GitHub easy (assuming you want source control, and I'd really definitely recommend it for even small projects).

Hi klab, we'll see if we can get some kind of OpenGL support going... As Cartroo says, that may not be easy, but we're always keen to support our users in whatever task they're doing, even (or especially) when a server computing environment isn't the most obvious place to do it!

So, as you say, although PA probably isn't the right place to develop GUI apps, and that's why we don't have packages like Tkinter or wx, there's no reason you can't do image manipulation, using the file browser to view results - that's why we have PIL. So we'll see what we can do about pyglet/psychopy and its GUL libraries..

@Cartroo: Thanks for a thorough answer. I am so used to psychopy rendering everything for me that I did not even consider using PIL (which I'm familiar with, in fact) for the task. This may be the most immediate solution. Converting PIL to numpy is as easy as numpy.asarray(image), so this is not a problem.

@harry: Cool! Looking forward to getting out of the box psychopy support :)

Let us know how it goes