psychopy.org | Reference | Downloads | Github

Good & bad experience with Linux + Psychopy1.90.0 + Python3.6

Short story, good news:
After some change (see long story below) psychoPy 1.90.0 works on Python 3.6 on Linux.

Short story, bad news:
Still, second screen cannot be used.

Long story, in the hope somebody can save time:

A) out of the box & pip install psychopy
All dependent packages will be fetched via pip, but errors occured:

  • In /tmp almost 3GB(!) were used (“no space left”, had to enlarge that, hope that helps others)
  • some more errors, long list, gave up that way.

B) all packages in environment via conda install (from info before)
then again pip install psychopy
install seems ok
but psychopyApp.py crashes immediately with seg-fault
gave up that way, too

C) download tar-ball from github
unpack
create new miniconda environment with the provided conda/environment-3.6.yml
=> ok
locally executed pip install .
=> ok
Start psychopyApp.py

ImportError: libpng12.so.0: cannot open shared object file: No such file or directory

Yes, Debian Stretch uses libpng16; so additionally installed 12 from Jessie
=> ok

Yes, psychopyApp starts
but loading Demos/timebyframes and starting gives

ModuleNotFoundError: No module named 'PyQt4'
(Yes, my System has Qt4 and Qt5 as shown by qtchooser -l)
Change sourcecode to matplotlib.use('Qt5Agg')

Yes, psychopyApp starts
and timing is very accurate! Great. Thanks!

Remaining Issue:
I need to run on the second (faster) screen, so changed screen=1 in timebyframes
win = visual.Window([1280, 1024], fullscr=True, screen=1, allowGUI=False, waitBlanking=True)

but no success, window still opens on 1st screen and program complains

0.7966 WARNING Requested an unavailable screen number - using first available.

If somebody could give me a hint, please, how to improve that?

Thanks a lot!
Best,
Uli

(edited layout and spelling mistakes)

Thanks for info.

A) seems like a pip problem (nothing to do with us) but I wonder why that isn’t affecting many people using pip for everything on linux :-/
B) no idea what that is

libpng: I wonder which package is needing/not-finding libpng. (It sure isn’t psychopy code itself that fails, so some dependent package needs fixing but which one?) Better if you could provide full error stack not just last line

pyqt: (this one I know to be about matplotlib, but it would have been better to give the full error, not just hte last line) This is a tricky one. Different systems have different best default backends for mpl, but good point that qt4 is not good for Py3

dual monitor: Might be a problem for pyglet on linux. Could you see what happens if you do:

win = visual.Window([1280, 1024], fullscr=True, screen=1, allowGUI=False, waitBlanking=True, winType='glfw')

GLFW backend is a new thing that @mdc has been developing and might have better dual-screen support?

Hi Jon, thanks a lot for your answer!

Sorry, the full Error messages are:
libpng

Traceback (most recent call last):
File “/home/wannek/miniconda3/envs/anaconda-py3/bin/psychopyApp.py”, line 96, in
start_app()
File “/home/wannek/miniconda3/envs/anaconda-py3/bin/psychopyApp.py”, line 22, in start_app
from psychopy.app._psychopyApp import PsychoPyApp
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/psychopy/app/_psychopyApp.py”, line 26, in
import wx
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/wx/init.py”, line 17, in
from wx.core import *
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/wx/core.py”, line 12, in
from ._core import *
ImportError: libpng12.so.0: cannot open shared object file: No such file or directory

pyqt

############ Running: /home/wannek/Code/psychopy190/timeByFrames.py ############

with 22: matplotlib.use(‘Qt4Agg’)

Traceback (most recent call last):
File “/home/wannek/Code/psychopy190/timeByFrames.py”, line 24, in
import pylab
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/pylab.py”, line 1, in
from matplotlib.pylab import *
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/pylab.py”, line 252, in
from matplotlib import cbook, mlab, pyplot as plt
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/pyplot.py”, line 115, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/backends/init.py”, line 62, in pylab_setup
[backend_name], 0)
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/backends/backend_qt4agg.py”, line 9, in
from .backend_qt5agg import (
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5agg.py”, line 15, in
from .backend_qt5 import (
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py”, line 19, in
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/figureoptions.py”, line 20, in
import matplotlib.backends.qt_editor.formlayout as formlayout
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/formlayout.py”, line 54, in
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/matplotlib/backends/qt_compat.py”, line 153, in
from PyQt4 import QtCore, QtGui
ModuleNotFoundError: No module named ‘PyQt4’

And thanks for the hint for glfw

apt-get install libglfw3
pip install glfw (Successfully installed glfw-1.5.1)

But

############ Running: /home/wannek/Code/psychopy190/timeByFrames.py ############

with 26: win = visual.Window([1280, 1024], fullscr=True, screen=1, allowGUI=False, waitBlanking=True, winType=‘glfw’)

Traceback (most recent call last):
File “/home/wannek/Code/psychopy190/timeByFrames.py”, line 28, in
win = visual.Window([1280, 1024], fullscr=True, screen=1, allowGUI=False, waitBlanking=True, winType=‘glfw’)
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/psychopy/visual/window.py”, line 375, in init
self.backend = backends.getBackend(win=self, *args, **kwargs)
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/psychopy/visual/backends/init.py”, line 25, in getBackend
from .glfwbackend import GLFWBackend as Backend
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/psychopy/visual/backends/glfwbackend.py”, line 48, in
WINDOW_ICON = Image.open(‘psychopy/monitors/psychopy.ico’)
File “/home/wannek/miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/PIL/Image.py”, line 2543, in open
fp = builtins.open(filename, “rb”)
FileNotFoundError: [Errno 2] No such file or directory: ‘psychopy/monitors/psychopy.ico’
Exception ignored in: <bound method Window.del of <psychopy.visual.window.Window object at 0x7ff13fccd908>>
(and a close error because None before)

But file(s) exist:

find . -name psychopy.ico
./opt/psychopy-1.90.0/psychopy/monitors/psychopy.ico
./opt/psychopy-1.90.0/psychopy/app/Resources/psychopy.ico
./miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/psychopy/monitors/psychopy.ico
./miniconda3/envs/anaconda-py3/lib/python3.6/site-packages/psychopy/app/Resources/psychopy.ico

Thanks a lot for helping!
Best,
Uli

The icon problem seems like an easy fix. It worked fine on my Windows and Linux systems, however I was using PyCharm which might have setup the appropriate paths. I’ll issue a correction in the next point release.

Hi mdc,
thanks for your answer! What do you suggest as a proper path workaround in the mean time? Hard coding version-related paths is not really nice.
Best,
Uli

You might need to do that as I haven’t fully investigated the issues.

Ok, made path relative
_WINDOW_ICON_ = Image.open('../../../monitors/psychopy.ico')

Result: Window opens. Fullscreen ok, timing ok, looks good!.

But still always only on Screen0, same Warning message, if tried with Screen=1.

Side effect: if provided with “wrong” resolution, but fullscreen=True, then canvas behaves like a window (an always-on-top windows stays on top) and resolution is zoomed. And timing is ugly, tearing visible.

Hello,

The results with the wrong resolution is intentional as the GLFW backend supports forcing the display into specific video modes needed for some planned features. However it should put itself into a default mode if the resolution specified is not a supported video mode.

Are you using a “spanned” desktop, where the driver treats both monitors as a single display? A solution would be to create a window with “allowGUI=False”, set its size to the dimensions of your display, and set the position of the window to the top corner of your second display on the virtual screen.

Hi mdc, thanks a lot for helping!

Yes,the intention is nice - and works.
What I wondered about is the other window staying on top (does that mean, the stimulus content is rendered through the system, not directly, and thus slower?)

Spanned? No, I have two independent “zaphodheads”, because my intention is to drive the 2nd (stimulus) monitor at it’s 120Hz - with really accurate frame-by-frame timing. Even now, on the “wrong” and slow (control) monitor, I observe strong tearing, which isn’t visible if just one screen is used.

Each display using its own X server might be the issue here. I’m not sure Pyglet or the GLFW bindings as-is have a good way of dealing with that. I’ll look into it further, it may require a more complex solution.

For the icon, I would suggest:

from psychopy import prefs
from os import path

_WINDOW_ICON_ = Image.open(
    path.join(prefs.paths['resources'], 'psychopy.ico')
    )

Or maybe use the png file, which is also in the resources folder?

Looks good, I’ll patch it.

GLFW on multiple monitors
Before, I used different X-screens. Now I tried a single desktop on a single X-screen across the two monitors.

good news:

  • refresh rate on fast stimulus monitor is recognized as 120fps
  • on control monitor 60fps

bad news:

  • timing is worse compared to single setup
  • more “noise” in timing histogram
  • dropouts (few ~ 1%)
  • tearing visible

strange (as observed before, different thread from Sept./Okt. last year)

  • Stimulus window always opens on same screen as the App is started from, independent of setting Screen=0 or Screen=1
  • If Screen=x is same as started, behaviour is normal
  • If Screen=y is the opposite, this other monitor shortly goes black and resumes
    • but eventually with a different refresh rate during program runs
    • and resumes after closing of output window to its previous state

Does this mean, pyglet(?) tries to start on intended monitor but somehow fails, falling back to same as App?
No error messages related to that.
Always fullscreen with correct resolution.

@uliw, @jon: Concerning B), the Segmentation fault in the pip install, I have the same and raised a GitHub issue here. I also reported how to make it work using pip3 install! +1 for the python3 version!