| Reference | Downloads | Github

Error with Bits++ box on 1.85.3b


I’m getting an error when setting up the Bits# box on 1.85.3b which wasn’t there on the previous version. The same error occurs with the demo files too, so I suspect it’s not my coding.

Here’s the error output from the CRS_BitsBox demo file which I’ve edited and resaved as CRS_BitsBoxDemo only to refer to the right monitor here. Any advice would be welcome, in the meantime I’ve rolled back to 1.85.2 and all is working fine (other than then nudge to update!)

################## Running: C:\Python Code\ ##################
1.6479 ERROR avbin.dll failed to load. Try importing psychopy.visual
as the first library (before anything that uses scipy)
and make sure that avbin is installed.
2.5811 INFO Opened port COM1 but it didn’t respond like a CRS Bits#
2.9560 INFO Opened port COM3 but it didn’t respond like a CRS Bits#
3.3379 INFO Opened port COM4 and looks like a CRS Bits#
3.4405 INFO Successfully opened COM4 with a CRS Bits#
Traceback (most recent call last):
File “C:\Python Code\”, line 26, in
bits = crs.BitsSharp(win=win, mode=‘bits++’)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\hardware\crs\”, line 530, in init
ok = self.checkConfig(level=checkConfigLevel)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\hardware\crs\”, line 810, in checkConfig, self.config.identityLUT)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\”, line 74, in setGammaRamp
0xFFFFFFFF & pygletWindow._dc, newRamp.ctypes) # FB 504
TypeError: unsupported operand type(s) for &: ‘long’ and 'LP_c_void’
3.4415 INFO Switched $ProductType;Display++ to bits++ mode

I get this problem with 1.85.3b also (not any previous version). So far I’ve tracked the problem back to pygletWindow._dc being of type LP_c_void when it is references by so I am assuming that its not being set correctly but I can’t find where it is set (I’m guessing possibly not within PsychoPy at all).

Update: if you roll back pyglet to the version shipped with PsychoPy 1.85.2 (I think pyglet version 1.2.4) this issue goes away so my guess is that the newer version of pyget does not set the value of its ._dc member but that expects it to be set. I don’t know critical the verion of pygletis to PsychoPy 1.85.3b install but maybe there is a workaround for this any ideas @jon.

This turns out to be a bug in Pyglet. It can be fixed by opening:
and commenting-out line 81:

 c_void_p = POINTER_(c_void)

I’m uploading a windows release 1.85.4 that contains this pyglet fix.

FYI making this fix might break some pyglet issues on 64bit python but that isn’t the version we distribute. (And I haven’t got a windows 64bit python to test that theory on!)

I’m having this problem also, and rolling back pyglet to 1.2.4 fixes it for me. I’m just starting to work with PsychoPy, and am using anaconda and pip to install things, so I’m not using the standalone Windows installer. (Windows 7&10 64-bit).

I’m trying to get an experiment running that was created with a standalone version of psychopy onto my installation. I’ve also run into a problem with pyHook, and I can’t download the Windows installer for that, so I used pip to install pyWinhook. Along with downgrading pyglet, I needed to modify iohub/ (line 637) and iohub/devices/keyboard/ (line 13) to import pyWinhook as pyHook.

import pyWinhook as pyHook

        # Add Device Monitor for Keyboard or Mouse device type 
        if device_class_name in ('Mouse','Keyboard'):
            if Computer.system == 'win32':
                import pyWinhook as pyHook

Maybe this could be incorporated into the non-standalone installation?

I forgot to mention that pyglet>1.3.0 doesn’t work either on python 2.7. Here’s what you get:

Python 2.7.14 |Anaconda, Inc.| (default, Nov 8 2017, 13:40:45) [MSC v.1500 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

from psychopy import visual
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\psychopy\”, line 17, in
from .window import Window, getMsPerFrame, openWindows
File “C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\psychopy\visual\”, line 57, in
from psychopy import core, platform_specific, logging, prefs, monitors, event
File “C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\psychopy\”, line 44, in
from pyglet.window.mouse import LEFT, MIDDLE, RIGHT
File “C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\pyglet\”, line 1769, in
from pyglet.window.win32 import Win32Window as Window
File “C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\pyglet\window\”, line 59, in
from pyglet.canvas.win32 import Win32Canvas
File “C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\pyglet\”, line 99, in
from pyglet.canvas.win32 import Win32Display as Display
File “C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\pyglet\canvas\”, line 7, in
from pyglet.libs.win32 import _kernel32, user32, types, constants
File "C:\Users\timothy.j.williams1\Anaconda3\envs\psychopyenv\lib\site-packages\pyglet\libs\win32_init
.py", line 237, in
_user32.GetRawInputData.argtypes = [HRAWINPUT, UINT, LPVOID, PUINT, UINT]
NameError: name ‘PUINT’ is not defined

Check out this thread on pyglet-users:

PUINT traceback

Yes, your options are:

  • Use PsychoPy standalone (where I’ve patched the problem in the pyglet lib)
  • Use your own installation of pyglet (e.g. anaconda) and then patch it yourself as I describe above
  • Install pyglet from source (from the bitbucket repository) because it has already been fixed, just not released
  • Wait for a pyglet release that includes it (1.4.1?)
  • downgrade to 1.2.4