# Trouble with visual.Window() and LabJackPython

**URL:** <https://discourse.psychopy.org/t/trouble-with-visual-window-and-labjackpython/8579>\
**Category:** Coding\
**Created:** [July 19, 2019, 2:56pm UTC](https://discourse.psychopy.org/t/trouble-with-visual-window-and-labjackpython/8579 "2019-07-19T14:56:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WillHinkle](https://avatars.discourse-cdn.com/v4/letter/w/e480ec/32.png) [@WillHinkle](https://discourse.psychopy.org/u/WillHinkle)\
**Post date:** [July 19, 2019, 2:57pm UTC](https://discourse.psychopy.org/t/trouble-with-visual-window-and-labjackpython/8579/1 "2019-07-19T14:57:00Z")

</div>

I am writing a code that uses LabJackPython to trigger a stimulus through Psychopy. The code returns the same error every time it is run. The terminal returns this:

```auto
2019-07-19 10:50:45.146 Python[43341:436948] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
  File "/Volumes/Pain_lab_data/IDP/new_scale/labjack_scales.py", line 80, in <module>
    units='height')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psychopy/visual/window.py", line 389, in __init__
    self.backend = backends.getBackend(win=self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psychopy/visual/backends/ __init__.py", line 32, in getBackend
    return Backend(win, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psychopy/visual/backends/pygletbackend.py", line 101, in __init__
    defDisp = pyglet.window.get_platform().get_default_display()
AttributeError: module 'pyglet.window' has no attribute 'get_platform'
Exception ignored in: <function Window. __del__ at 0x1260b0830>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psychopy/visual/window.py", line 501, in __del__
    self.close()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psychopy/visual/window.py", line 1327, in close
    self.backend.close() # moved here, dereferencing the window prevents
AttributeError: 'NoneType' object has no attribute 'close'

```

I believe the problem derives from the visual.Window() as the first error on line 80 is the last line in the visual.Window(). Here is the code for that section:

```auto
win = visual.Window(
    size=[1920, 1080], fullscr=True, screen=0,
    allowGUI=True, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True,
    units='height')

```

pyglet is version 1.4.1, Psychopy version 3.1.4, python version 3.7.4.

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [July 22, 2019, 2:32am UTC](https://discourse.psychopy.org/t/trouble-with-visual-window-and-labjackpython/8579/2 "2019-07-22T02:32:10Z")

</div>

> [@WillHinkle](#):
>
> AttributeError: module ‘pyglet.window’ has no attribute ‘get\_platform’

It is worth searching this forum for your error message, to see if someone else has had the same issue:

> [@visual.Window() error](https://discourse.psychopy.org/t/visual-window-error/8578/3):
>
> Your version of pyglet might be too new. Depending on how you have Python set up, something like pip install pyglet==1.3.2 would downgrade pyglet.
