We will be using the Anaconda distribution of Python (2.7). This section will guide you on installing Anaconda, PsychoPy, pyo, and Sublime Text. We will be using the Anaconda environment which is bundled with lots of packages for scientific computing, allows you to more easily install packages and create virtual environments, and comes with a handy IDE (Integrated Development Environment) called Spyder.
We'll be using various shell commands in the class. Windows terminal (cmd
) is pretty crummy and although there is a Linux shell now available for Windows 10, the shell is not integrated with the Windows system making its use very inconvenient. As a solution we'll use Cmder
.
Open it by double clicking on Cmder.exe. Pin it to the taskbar. Now start an Administrator shell like so:
Navigate to the directory containing Cmder using cd
. You can verify by typing ls
and making sure you see Cmder.exe in the list.
To integrate Cmder with Windows explorer type .\cmder.exe /REGISTER ALL
in the Cmder prompt
Now you can right click on any directory in Windows explorer and choose to open the contents with Cmder.
For simplicity, we'll install all the Python packages we'll need into the root
environment of Anaconda. If you want a separate environment for PsychoPy
, see Creating a virtual environment. If you don't know what virtual environments are and want to learn, see here
Cmder
and paste in the following commands, press enter
and wait for everything to install:conda install spyder jupyter psutil
pip install numpy scipy matplotlib pandas pyopengl pyglet==1.2.4 pillow moviepy lxml
pip install openpyxl configobj future json_tricks wxpython pypiwin32
pip install psychopy
====
python
, now instead of the Mac-bundled Python, you should see something like:$ python
Python 2.7.14 |Anaconda, Inc.| (default, Nov 8 2017, 13:40:13) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
====
PsychoPy
installed correctly. At the python prompt type:>>> import psychopy
>>> psychopy.__version__
'1.85.3'
If you see this, you know that the PsychoPy library installed correctly.
>>>from psychopy import visual
>>>visual.Window((400,400),color="green")
When you hit enter after the second line, you should see a small green window.
===
spyder
. You should see something like this:
If that looks a like RStudio, that's because all these IDEs are descended from a common ancestor.
pyo
package which PsychoPy
uses to play audio files with low(er) latencies. There are other alternatives for playing sounds, but in my testing, pyo
consistently produces more robust performance.Download and install PYO from here.
===
python
, then:>>>import pyo
pyo version 0.8.0 (uses single precision)
If you see this, all is good.
Sublime Text is a popular text editor with a very large collection of plugins and themes that allow you to make it anything you want it to be. It is not free, but has a generous trial-use policy. If you like it, please purchase a license.
To install Sublime Text, go to the Downloads page, and click on the Windows installer.
To use it efficiently, you'll want to learn some keyboard shortcuts.
There are lots of handy packages for Sublime Text. To install them, you'll want to first install Package Control which allows you to browse and install packages directly from within Sublime Text. Some especially handy ones are Origami, SublimeREPL, AdvancedCSV, and Terminal.
alias
. Using Sublime Text, open the user-aliases.cmd
file inside cmder\config
(cmder is inside whatever directory you're using it from).
Add an alias to Sublime Text by adding the following line into user-aliases.cmd
.
s="C:\Program Files\Sublime Text 3\sublime_text.exe" $1
Save the file and restart Cmder. Now you should be able to open any file inside Sublime Text using s
, e.g., s my_file.txt
===
If you already have a Anaconda environment that you're happy with, and don't want to mess with, or you want to create a separate Python environment for this class, execute the following two lines at the Terminal before following the package installation instructions:
conda create -n psychopy pip
source activate psychopy