Search code examples
pythonuser-interfacepsychopy

Inconsistent Import Error in Python


I just have a quick question about an error I've been getting when I try to import:

from psychopy import gui

So if I try to import this code in one program I have no problems, however, if I try to import it in another I get:

"ImportError: cannot import name gui"

Does anyone know why this might be happening? Why does it work for one problem, but not the other? Also, I feel like it wasn't doing this before, and it just started suddenly. Any advice would be greatly appreciated.


Solution

  • UPDATE: I think Jon's answer is the correct one. If I was right, you should get an error "no module named psychopy".


    Given that you tagged this question with the psychopy tag, my guess is that it works if you run it from the psychopy app and that it doesn't work if you run it from another editor or command line.

    The reason is that psychopy is currently shipped as a bundle that comes with it's own python and a lot of modules/dependencies, including psychopy. The system is not made aware of these modules via the PYTHONPATH.

    You can make them available system-wide by either (1) following the steps outlined here or (2) use the conda based installation described in this post in the psychopy-dev list. The latter feature is still work in progress but will probably eventually mature to be the default install option.