Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name app #11

Closed
grokkerino opened this issue Dec 17, 2014 · 30 comments
Closed

ImportError: cannot import name app #11

grokkerino opened this issue Dec 17, 2014 · 30 comments

Comments

@grokkerino
Copy link

I have tried installing glumpy both via pip and through the pymor ubuntu ppa repository but get the same results, even after reinstalling and reconfiguring multiple related packages. All dependencies are installed per the installation instructions.

import numpy as np
from glumpy import app, gl, gloo
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name app

Oddly, if I just do the following, I get an empty window.

import glumpy
glumpy.Window()
<glumpy.window.backend_glut.Window object at 0x18884d0>

Here's another example

import glumpy
img = glumpy.graphics.Image("data/lena.png", anchor_x = 'center', anchor_y = 'center')
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'Image'

I'm utterly confused, I've spent 3 hours on this and can find nothing relevant.
I'm using python 2.7.

@rougier
Copy link
Member

rougier commented Dec 17, 2014

Sorry for that. The best way is to use the git version:

git clone https://github.com/glumpy/glumpy.git
cd glumpy
python setup.py install
cd examples
./app-simple.py

If this does not work, can you send the traceback here ?

@grokkerino
Copy link
Author

Is there a way to force a specific backend to be default?

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Yes, edit glumpy/defaults.py (search for backend).

@grokkerino
Copy link
Author

Ahh, tried this before. It still says it needs an updated version of glfw:

Traceback (most recent call last):
File "./app-simple.py", line 7, in
from glumpy import app
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/init.py", line 8, in
from . app import run
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/init.py", line 17, in
from glumpy.ext.inputhook import inputhook_manager, stdin_ready
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/ext/init.py", line 6, in
from . import glfw
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/ext/glfw.py", line 76, in
raise OSError('Need GLFW library version 3, found version %s' % version)
OSError: Need GLFW library version 3, found version 2.7.2

so I compiled and installed an updated version of glfw, 3.0.4 with the default backend set to freeglut

Traceback (most recent call last):
File "./app-simple.py", line 7, in
from glumpy import app
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/init.py", line 8, in
from . app import run
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/init.py", line 23, in
from . console import Console
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/console.py", line 9, in
from glumpy import gl, glm, gloo
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/init.py", line 14, in
from . framebuffer import FrameBuffer, ColorBuffer, DepthBuffer, StencilBuffer
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/framebuffer.py", line 155, in
class StencilBuffer(RenderBuffer):
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/framebuffer.py", line 169, in StencilBuffer
def init(self, width, height, format=gl.GL_STENCIL_INDEX8):
AttributeError: 'module' object has no attribute 'GL_STENCIL_INDEX8'

There's a new error while trying to import app, so that's an improvement :)

@grokkerino
Copy link
Author

oops, I meant I first changed the default backend to freeglut and it still wanted glfw which is when I compiled and installed glfw3.0.4

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Can you try:

$ ipython
>>> import OpenGL.GL as gl
>>> gl.GL_STENCIL [+ hit tab]

(This is to get all GL_STENCIL_ constants)

@grokkerino
Copy link
Author

In [3]: gl.GL_STENCIL
gl.GL_STENCIL
gl.GL_STENCIL_ATTACHMENT_EXT
gl.GL_STENCIL_BACK_FAIL
gl.GL_STENCIL_BACK_FAIL_ATI
gl.GL_STENCIL_BACK_FUNC
gl.GL_STENCIL_BACK_FUNC_ATI
gl.GL_STENCIL_BACK_PASS_DEPTH_FAIL
gl.GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI
gl.GL_STENCIL_BACK_PASS_DEPTH_PASS
gl.GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI
gl.GL_STENCIL_BACK_REF
gl.GL_STENCIL_BACK_VALUE_MASK
gl.GL_STENCIL_BACK_WRITEMASK
gl.GL_STENCIL_BITS
gl.GL_STENCIL_BUFFER
gl.GL_STENCIL_BUFFER_BIT
gl.GL_STENCIL_CLEAR_VALUE
gl.GL_STENCIL_FAIL
gl.GL_STENCIL_FUNC
gl.GL_STENCIL_INDEX
gl.GL_STENCIL_INDEX16_EXT
gl.GL_STENCIL_INDEX1_EXT
gl.GL_STENCIL_INDEX4_EXT
gl.GL_STENCIL_INDEX8_EXT
gl.GL_STENCIL_PASS_DEPTH_FAIL
gl.GL_STENCIL_PASS_DEPTH_PASS
gl.GL_STENCIL_REF
gl.GL_STENCIL_TEST
gl.GL_STENCIL_TEST_TWO_SIDE_EXT
gl.GL_STENCIL_VALUE_MASK
gl.GL_STENCIL_WRITEMASK

:(

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Can you try to replace the GL_STENCIL_INDEX8 with GL_STENCIL_INDEX8_EXT ?

@grokkerino
Copy link
Author

Already ahead of you.. Now:

Traceback (most recent call last):
File "./app-simple.py", line 7, in
from glumpy import app
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/init.py", line 14, in
from . graphics.filter import *
ImportError: No module named filter

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Weird, you can remove the line but it is supposed to work.

@grokkerino
Copy link
Author

I removed that "from . graphics.filter import *" from the root init.py and now its saying the same for collection.. after commenting that out it complains about not having freeglut. Recompiling with default of glfw and fixing stencil_index8 agai nI am back to the no module named filter.

@rougier
Copy link
Member

rougier commented Dec 18, 2014

But you commented the filter line, no ?

@grokkerino
Copy link
Author

Yup, after commenting out both graphics.filter and graphics.collection I now get:

Traceback (most recent call last):
File "examples/app-simple.py", line 9, in
window = app.Window()
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/init.py", line 183, in new
config = configuration.gl_get_configuration()
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/configuration.py", line 265, in gl_get_configuration
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
AttributeError: 'module' object has no attribute 'glBindFramebuffer'

I'm guessing this is a versioning thing.. so even if I change a few calls there will be 100 more to change.

@rougier
Copy link
Member

rougier commented Dec 18, 2014

What is your system and graphic card ?

@grokkerino
Copy link
Author

Ubuntu 12.04, running bumblebee which requires a special command to run under the nvidia portion of the nvidia/intel split graphics card. I hadn't thought of that and just tried it. still same problem with glBindFramebuffer

rougier added a commit to rougier/glumpy that referenced this issue Dec 18, 2014
@rougier
Copy link
Member

rougier commented Dec 18, 2014

Ok. I've surrounded the line with try/except. It's only for configuration reading so not really essential. You can pull or add:

    try:
        gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
    except:
        log.warn("Cannot bind framebuffer")

@grokkerino
Copy link
Author

Get a black window now with nothing happening.. tried a few other examples, nada. (Except for some complaints about VertexBuffer object has no attriute '_handle' but that's not relevant yet)

[w] no fb
[w] Cannot read RED channel size from the framebuffer
[w] Cannot read GREEN channel size from the framebuffer
[w] Cannot read BLUE channel size from the framebuffer
[w] Cannot read ALPHA channel size from the framebuffer
[w] Cannot read DEPTH size from the framebuffer
[w] Cannot read STENCIL size from the framebuffer
[w] Cannot read sRGB value from the framebuffer
[i] Using GLFW (GL 3.0)
[i] Running at 60 frames/second

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Can you try the app-events.py ?

@grokkerino
Copy link
Author

[w] no fb
[w] Cannot read RED channel size from the framebuffer
[w] Cannot read GREEN channel size from the framebuffer
[w] Cannot read BLUE channel size from the framebuffer
[w] Cannot read ALPHA channel size from the framebuffer
[w] Cannot read DEPTH size from the framebuffer
[w] Cannot read STENCIL size from the framebuffer
[w] Cannot read sRGB value from the framebuffer
[i] Using GLFW (GL 3.0)
[i] Running at 10 frames/second
Initialization
Window resized (width=512.0, height=512.0)
Timed event (1.00 second(s) elapsed)
Timed event (1.00 second(s) elapsed)
Timed event (1.00 second(s) elapsed)
Timed event (1.10 second(s) elapsed)
Timed event (1.00 second(s) elapsed)
Timed event (1.10 second(s) elapsed)
Mouse motion (x=494.3, y=223.1, dx=494.3, dy=223.1)
Mouse motion (x=446.9, y=204.7, dx=-47.4, dy=-18.4)
Mouse motion (x=395.1, y=190.0, dx=-51.9, dy=-14.7)

@rougier
Copy link
Member

rougier commented Dec 18, 2014

And the window is black also ?

@grokkerino
Copy link
Author

yup

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Can you try to add:

gl.glClearColor(1,1,1,1)
gl.glClear(gL.GL_COLOR_BUFFER_BIT)

in the display method in app-events.py example

@grokkerino
Copy link
Author

now its white

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Cool, at least basic GL is working.
What about app-two-programs.py ? (you should get 2 points )

@grokkerino
Copy link
Author

Yup!

@rougier
Copy link
Member

rougier commented Dec 18, 2014

gloo-* examples are also working ?

@grokkerino
Copy link
Author

Getting a vertexuffer error most of the other examples get:

[w] no fb
[w] Cannot read RED channel size from the framebuffer
[w] Cannot read GREEN channel size from the framebuffer
[w] Cannot read BLUE channel size from the framebuffer
[w] Cannot read ALPHA channel size from the framebuffer
[w] Cannot read DEPTH size from the framebuffer
[w] Cannot read STENCIL size from the framebuffer
[w] Cannot read sRGB value from the framebuffer
[i] Using GLFW (GL 3.0)
[i] Running at 60 frames/second
Traceback (most recent call last):
File "./gloo-trail.py", line 122, in
app.run(framerate=60)
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/init.py", line 295, in run
clock = init(clock=clock, framerate=framerate, backend=backend)
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/init.py", line 259, in init
window.dispatch_event('on_resize', window._width, window._height)
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/window/event.py", line 371, in dispatch_event
if getattr(self, event_type)(_args):
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/window/window.py", line 187, in on_resize
self.dispatch_event('on_draw', 0.0)
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/app/window/event.py", line 361, in dispatch_event
if handler(_args):
File "./gloo-trail.py", line 91, in on_draw
program.draw(gl.GL_POINTS)
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/program.py", line 467, in draw
self.activate()
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/globject.py", line 90, in activate
self._activate()
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/program.py", line 321, in _activate
attribute.activate()
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/globject.py", line 97, in activate
self._update()
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/variable.py", line 350, in _update
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.data.handle)
File "/usr/local/lib/python2.7/dist-packages/glumpy-2.0-py2.7-linux-x86_64.egg/glumpy/gloo/globject.py", line 115, in handle
return self.base._handle
AttributeError: 'VertexBuffer' object has no attribute '_handle'

rougier added a commit to rougier/glumpy that referenced this issue Dec 18, 2014
@rougier
Copy link
Member

rougier commented Dec 18, 2014

Strange. I tried to push a fix but I don't know if it will work.

@grokkerino
Copy link
Author

No go.
AttributeError: 'VertexShader' object has no attribute 'base'

And even commenting out this 2 line base portion I get:
AttributeError: 'VertexBuffer' object has no attribute '_handle'

Changing 'return self._handle' to 'return self.handle' gets a max recursion error.
RuntimeError: maximum recursion depth exceeded

As you're working on vispy I'd say lets just close it.. Noone has reported anything remotely similar to what I've encountered.

@rougier
Copy link
Member

rougier commented Dec 18, 2014

Yes, but if you get the bug, some others will get it...
In the meantime, vispy is a better option.

@rougier rougier closed this as completed Dec 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants