PyschoPy for Miniconda / Anaconda on OSX (where pyglet and pygame also work!)

244 views
Skip to first unread message

Kathryn Schuler

unread,
May 6, 2016, 8:39:40 AM5/6/16
to psychopy-dev
Hi friends,

Writing to share how I run PsychoPy with Miniconda (Anaconda's minimalist conda distribution) on OSX.  Getting this to work has been somewhat tricky in the past because of a few complications (for me, these complications were mostly pyglet and pygame).  But now, lots of people on the internet have solved these problems, so it is a bit easier.  I thought I'd post how I do this, just in case others in the community are interested. (These instructions would obviously also work for full Anaconda.)

Some disclaimers:
(1) This is how I run all of my experiments in our lab, which make heavy use of psychopy.visual, sound, and data. I haven't used any video. 
(2) It has worked on several different Mac machines, all running between 10.6 and 10.10 (but I do not have evidence of success beyond our lab computers)
(3) I use .csv files (and not .xlsx), so my experiments don't test openpyxl (but the conda recipe retrieves it, so it may work ok)
(4) I don't use psychopy.gui normally.  When I do, I have to run experiments with [ pythonw experimentfile.py  ] because gui really wants a Framework build of python, and using pythonw forces that situation.
(5) To use pygame for sound, you need to make sure psychopy chooses it (and not pyo).  I do this by putting this at the top of my scripts
from psychopy import prefs
prefs.general['audioLib'] = ['pygame']


OK, on to the good stuff.

Get Miniconda 
# if you already have anaconda or miniconda, you can skip this part
# download and install the latest distribution of miniconda or anaconda for OSX (64-bit is the only option)
bash Miniconda2-latest-MacOSX-x86_64.sh     

# answer 'yes' to all of the questions
# close and then reopen the terminal to start using conda
# check that miniconda is installed
conda info

# miniconda adds itself to your path to become your default python.  check that this is true
which python

# and make sure that everything is up to date
conda update conda

Get Psychopy 
# use conda to get psychopy and its dependents
# I've created a new recipe based (heavily) on Erik's previous recipe with the following changes:
# (1) gets psychopy version 1.82.01
# (2) gets pandas (because miniconda doesn't come with it)
# (3) stops getting pyglet (this version of pyglet had a bug for OSX<10.10)
# you can install it in anaconda using
conda install -c kschuler psychopy=1.82.01

Get pygame and pyglet
# To run your experiments in psychopy, you'll probably want both pyglet and pygame.
# If you were hoping for pyo - me too! But there isn't an easy solution to that, yet. 
# (pyo is not compatible with 64-bit python, which is the only anaconda option on OSX)
# Both pygame and pyglet require a tiny bit of extra effort to get them into your conda environment.

pygame
# Pygame is probably going to be most important for people who use sound. That is because psychopy has two sound options:
# (1) pyo - which, as mentioned above, is not currently compatible with 64-bit python (and 64-biy python is the only anaconda option for OSX)
# (2) pygame - which is a great package, but has been kind of a bear to get installed.
# The first big problem for pygame is that it requires a bunch of dependencies that are hard to get right in conda.  
# But it works easily when you use homebrew - so lets just do that
# get homebrew (skip this if you already have it)

# and install the pygame dependencies with it
brew install sdl sdl_ttf sdl_image sdl_mixer portmidi

# the second big problem is that the official repository for Pygame doesn't build properly on OSX.  
# So we have to retrieve Pygame from a special place (binstar) that does build properly.
# to do this, we need to install anaconda-client
conda install anaconda-client

# and then we can install (the OSX friendly) pygame
conda install -c https://conda.binstar.org/quasiben pygame

pyglet
# all that we have left to do is install pyglet.
# here the problem is that conda really wants to pull pyglet1.2.1, which has that OSX10.10 bug.
# and we really want conda to pull pyglet1.2.4 (which has that bug fixed)
# There is most definitely a way to get this to work in conda, but it has consistently given me trouble.
# (And the goal for me is for this to be easy so that others can use my conda environments to run my experiments without issues)
# installing pyglet with pip works like a dream for psychopy.  So I'm content with just doing that

# first create your conda enviroment for psychopy.  You can name it whatever you want, but I like psychopyenv
# and tell your environment to have psychopy and pygame
conda create -n psychopyenv psychopy pygame

# then you can navigate to your environment
source activate psychopyenv

# and install pyglet with pip
pip install pyglet


Things should work!
Hope this helps!

Katie







Jonathan Peirce

unread,
May 6, 2016, 8:55:04 AM5/6/16
to psycho...@googlegroups.com
Hi Katie

Thanks for this. I'm sure it will help many people that want a custom python install :-)

On the pyo issue, I've also been unable to compile pyo into 64bit myself (at least, not a 64bit version that works on older versions of OSX) but I recently found that I could download a precomiled version on mac.softpedia. Doesn't mention it on the pyo website but it seems to work
    http://mac.softpedia.com/get/Developer-Tools/pyo.shtml
Am currently testing that it works on other versions of OSX than my development machine. The downside to the fact that he compiled it is that it has annoying messages about creating the pyo servers etc (that's something that can only be turned off at compile time :-( )

Also... I'm hoping to have full support for pysoundcard soon (= much easier to install) but need to do some timing tests with it first to see how it performs. PsychoPy repository has the preliminary code for this included as an option in sound.py

best wishes and thanks again
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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.
Reply all
Reply to author
Forward
0 new messages