| Reference | Downloads | Github

ImportError: cannot import name 'backend'

import psychopy  # so we can get the __path__
from psychopy import core, platform_specific, logging, prefs, monitors
import psychopy.event
**from . import backend**
# tools must only be imported *after* event or MovieStim breaks on win32
# (JWP has no idea why!)
from import attributeSetter, setAttribute
from import val2array
from import convertToPix
import as viewtools
from .text import TextStim
from .grating import GratingStim
from .helpers import setColor
from . import globalVars

    from PIL import Image
except ImportError:
    import Image

import numpy

from psychopy.core import rush

reportNDroppedFrames = 5  # stop raising warning after this

# import, pyglet.window, pyglet.image, pyglet.font, pyglet.event
from . import shaders as _shaders

hi, I have no idea about the “backend”. Is it a library for loading pictures?

And I am curious why ‘backend’ is imported from ‘.’ ? what is ‘.’ ?

thank you very much!

Hi @11111, the backends package is used to set up a context in which to draw objects in a Window, using either pyglet, pygame, or glfw. Each Backend class defines the core low-level functions required by a Window class, such as the ability to create an OpenGL context and flip the window.

The ‘.’ indicates a relative import - “A single dot means that the module or package referenced is in the same directory as the current location”. See absolute vs relative imports. In this instance, the window module imports the backends package using relative imports because the backends package is in the same directory as the window module, which contains the Window class used for drawing your stim etc.

thank you so much!!