| Reference | Downloads | Github

Running scripts from terminal hangs

UPDATE: I have narrowed it down to importing gui. I did the imports one at a time in ipython and everything from this line worked, until I got to gui and then it hung.

UPDATE 2: If I do from psychopy import gui first, it imports, but then doing from psychopy import core after than, gives me a pandas error?! How can the order of importing affect this? Any insight at this point would be greatly appreciated…I’m stumped.

from psychopy import core, data, event, logging, gui

Original Post:
I’m hoping someone will be able to help us with installing and running psychopy on a new lab laptop. We recently purchased a new macbook air running osx sierra for our lab. We have some task scripts that were written with psychopy a long time ago that run fine on our older mac laptops, but they won’t run on the new laptop.

I followed all the instructions on the psychopy installation page and installed everything manually via pip (all the python libraries) but have also installed psychopy via the dmg file. The scripts run fine if run through the psychopy program directly, but we need to run them from the terminal prompt.

When I run then from terminal, they appear to load and python in running (the python icon pops up in the dock) but it just hangs there. We have a prompt window that should pop up, but it doesn’t. Unfortunately I am unable to pinpoint what is hanging because there isn’t any output text or anything. It will just hang until I ctrl+C the script.

Has anyone run into this or have any ideas? Any help would be greatly appreciated.

I’ve read on several other posts that running things from iPython can complicate things and create problems. Have you tried running from a normal terminal?

Yeah, I initially was running it from terminal. My original post was describing that. I only went to ipython because when running from terminal it would just hang and I wouldn’t get any feedback as to what was happening. But basically, from terminal the python icon comes up, but the GUI pop up we have to enter info never appears.

I’m not sure if this is a coincidence, but when I was still installing the future library, it would work and the window would pop up, but it would give errors because it was looking for the future library to use divide.

I’ve gone back and updated/reinstalled everything and the same issue. Since it works on older MacBooks, I have a feeling it’s the updates os causing issues, but can’t figure out how to further troubleshoot this.

Bumping this. Can anyone offer some insight?

Well, I found a workaround and am posting it here in case anyone else experiences the issue (or if the devs read this and can address it in the next update).

It appears it had to do with the order and way we were importing modules from psychopy. This works fine on all of our laptops pre yosemite, but any with yosemite or sierra just hang. I had to import these one at a time and read the errors in ipython and then experiment with what order/grouping works. This is the oddest issue I’ve ever run across working with any python script, but it seems to work.

The original line was importing everything in one string:
from psychopy import core, data, event, logging, gui

The way we have to do it on any of the newer macbooks is like this (we also need to import the pandas modules directly rather than letting psychopy do it):
from pandas import DataFrame, read_csv
from psychopy import core, gui
from psychopy import data, event, logging

It’s a weird workaround, I know, but our scripts now run in the terminal. Hopefully this helps someone else.


Thanks for following up, that IS super weird! Hopefully someone has some type of clue as to why this could happen.

So just a follow up, I had to install on a mac and am running into this same problem. The problem occurs in gui/ , when PyQt4 and PyQt5 can’t be found and it tries to import wxgui. That’s where the hang starts. In my case I’m just going to install PyQt and hope this goes aways, don’t have too much time to dedicate to it.

This is line specifically where it hangs:

from .wxgui import *

I had this same issue on an iMac running Sierra, and iamdamion’s solution regarding the order of importing modules has worked, at least thus far.

Not sure why this is happening, but I appreciate being able to so easily find a fix.

On MacOS I installed Anaconda then added PsychoPy and its requirements with pip. That worked for me.

Make sure that when you invoke pip and python from the command line and that those refer to the ones inside the Anaconda directory. “which” will tell you. Pretty sure that the Anaconda installer sets it up that way, but it does not hurt to check to make sure.