Getting psychopy working with Spyder

2,453 views
Skip to first unread message

Tom Wallis

unread,
Jun 16, 2013, 4:28:25 PM6/16/13
to psychop...@googlegroups.com
Hello there,

I'm new to both psychopy and python, and am excited to learn. I'm very experienced with matlab / psychtoolbox. I'm hoping to use python more generally as a scripting language so I want to use a full-featured IDE and have started playing with Spyder. This is installed no trouble. Equally, the psychopy standalone installed with no trouble and can run demos / display stimuli (e.g. the drifting_plaid_demo.py script).

However, I am having difficulties getting psychopy to work through the terminal / Spyder. I note that both Spyder and the standalone Psychopy2 install seem to use their own python installations rather than the system. I've installed psychopy both through the standalone installer and through macports (both py-26 and the port just called "py-psychopy" -- what's the difference between these? Is it bad that I tried both?). 

If I open the python interpreter in a terminal, typing
help("modules")
shows me that the default system python can see the psychopy module. If I run a script 

python drifting_plaid_demo.py

I get the following error 

Traceback (most recent call last):
 
File "drifting_plaid_demo.py", line 2, in <module>
   
from psychopy import *
 
File "/Library/Python/2.7/site-packages/PsychoPy-1.77.00-py2.7.egg/psychopy/gui.py", line 8, in <module>
   
import wx
ImportError: No module named wx



If I run the script in Spyder I get the same error (albeit that I had to point Spyder to the psychopy directory in the set path first). As far as I've been able to tell I don't actually have a module called "wx" on my system (including in the psychopy.app package), yet psychopy runs happily through its standalone gui. 

Does anyone have any experience with setting up psychopy to run through Spyder? Apologies that this is more of a module management question in Python than a PsychoPy question.

Cheers

Tom

System: OSX 10.8.

Jonathan Peirce

unread,
Jun 17, 2013, 6:04:42 AM6/17/13
to psychop...@googlegroups.com
The standalone psychopy really will stand alone from any other installation. So it won't hurt that you've installed another psychopy by other means. The only place they will interact is that they will use the same user prefs file (and if they're different version this could cause errors).

The python that comes within spyder is likely just to be used to drive that application (spyder is itself entirely written in python), but I'm certain you can point spyder to use the system python for running scripts (but not for running itself, if you see what I mean). On mac you can't tell spyder to use the PsychoPy Standalone python for running scripts, so to use that to run psychopy you'll need you own installation, by macports or by using something like the academic version of enthought python distribution (use the 32bit version) and adding a small number of packages manually.

Now... to the specific problem you have. Whichever python you're using, it's missing the wxpython library. So you'll need to install that from here (or through macpports I imagine):
    http://wxpython.org/download.php
Given the choice you want the unicode version.

You'll probably get several more messages of things that are missing though, and you'll need to handle each in turn in a similar way (using enthought instaed of macports will probably mean fewer packages to install).

best wishes,
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/9f76f243-eae0-414b-974b-bff19ad9559b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.


Jonas Lindeløv

unread,
Jun 17, 2013, 4:13:43 PM6/17/13
to psychop...@googlegroups.com
I use Spyder for all my development work, both on Windows and Linux. It's actually quite easy to get working, once you have PsychoPy and Spyder installed. To make psychopy AND its modules available for import in Spyder, simply add two paths using Tools --> PYTHONPATH manager:

psychopy: [path to psychopy]\Lib\site-packages\PsychoPy-[version name].egg\
libraries: [path to psychopy]\Lib\site-packages\

On Windows [path to psychopy] = C:\Program Files (x86)\PsychoPy2\

Best,
Jonas

Tom Wallis

unread,
Jun 21, 2013, 12:51:43 AM6/21/13
to psychop...@googlegroups.com
Thanks for the replies Jon and Jonas.

Jonas: unfortunately it's not so simple under OSX since python is an application package, so you can't add a path through the PYTHONPATH manager.

I used the command

sys.path.append("/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/")

but then when I try
import wx

I get the following error:

ImportError: dlopen(/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/wx/_core_.so, 2): no suitable image found.  Did find:
/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/wx/_core_.so: mach-o, but wrong architecture

Thanks for the suggestions. I will keep trying.

Jonathan Peirce

unread,
Jun 21, 2013, 4:47:58 AM6/21/13
to psychop...@googlegroups.com
The python provided with Standalone PsychoPy does not work outside the app, for any editor/launcher. The way it's packaged using py2app doesn't allow that. So to use spyder to launch/debug your scripts you do need to use a manual install of python and dependencies.

Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages