From Lupyan_Lab_Wiki
Jump to: navigation, search

<sidebar>Psych711</sidebar> Installation instructions for PCs

Remove old python installations[edit]

Step zero: If needed: uninstall any versions of python that you have personally installed. This includes standalone PsychoPy. Don't touch your system version. Note: if you don't know what this means, just ignore it.

Install Python and Psychopy with its necessary libraries[edit]

Python Installation and Configuration[edit]

You will need to install Python and Psychopy, which is the experiment-building library we will be using. In this class we will use the Enthought Platform which includes Python 2.7 and all the libraries required by Psychopy.

  • Register for a free academic copy of Enthought Canopy by signing up with your academic email here. If you're having trouble downloading the full version of Canopy, let me know.
  • Check your email for a download link from Enthought. Download the Full install. You will need to download the 32-bit version even if you have 64-bit windows. The 64-bit version will cause compatibility problems with necessary libraries. The file is quite large so it may take a while to download. It's big because it includes numerous libraries for scientific computing, most of which we won't be using in the class, but you might find useful later on.
  • After downloading, run the file (something like canopy-1.2.0-full-win-32.msi). Install into the default directory - c:\Users\(your user name here)\AppData\local\Enthought\Canopy32\App.
  • When the installer finishes, launch the Canopy program to complete setup.
  • After setup is complete, you'll want to test to make sure Python has been added to your windows path so that you can access it from any directory. To test, go to the command prompt (Start : cmd : enter), and type python. If python starts up and mentions 'Enthought', you're all set (type exit() to end the python session. If you instead get an error message or you don't see the word Enthought, add the Python directory to your path by typing
C:\>setx path "%PATH%;C:\users\(your user name here)\appdata\local\enthought\canopy32\app\python27" at the prompt. After pressing Enter you should be informed that the command was successful. Try typing python at the prompt again to make sure it's now working.

Psychopy Installation[edit]

To install Psychopy you will need to download the library and run its setup script.

  • Download the psychopy library v1.84.1 and unzip it into c:\Python27
  • Open a command prompt (Start : cmd.exe)
  • Navigate to the python directory by typing cd c:\python27\Psycho and then hitting Tab to complete the rest of the directory name.
  • Then type python install.
  • After installation completes, type python to do some post-installation housekeeping. You may not see anything printed to the screen.

Install Cygwin[edit]

  • Unless you've already installed Cygwin on your system, please download the Custom Cygwin Installer and unzip it into a convenient location.
  • Run 'setup.exe' (make sure you're logged in as administrator)
  • Select 'Install from Local Directory'
  • For 'Root Directory' put c:\cygwin
  • Select Install for 'All Users'
  • For the local Package directory select the directory to which you unzipped the downloaded installer (it should default to the correct one)
  • After clicking 'next' you will then see a 'Select Packages' display. Click on the first 'Default' to change it to 'Install' (this should also change all the subsequent options to 'Install').
  • Hit next. Installation will take a few minutes.
  • Check the boxes that ask if you want to make a shortcut to the desktop, etc.
  • Run by clicking on the cygwin.icon on your desktop after installation.
  • The installer will install about 50mb of doc files you probably don't need. To delete them type: rm -r /usr/share/doc at the cygwin command prompt.

Install Notepad++[edit]

One plugin I recommend is autosave which will automatically save unnamed text files. To install plugins (a simple matter), please follow the instructions at the top of this page
When you install the autosave plugin and start Notepad++ you may get a dialogue box with the message
"This ANSI plugin is note compatible with your Unicode Notepad++.. Do you want to remove this plugin from plugins directory to prevent this message from the next launch time?"
You can click yes to delete the plugin. Autosave will continue to work. Autosave installs two versions of itself (one works, the other doesn't). You're merely deleting the non-working version.

Install ImageMagick[edit]

Tweak the working environment and test a couple things[edit]

First, if you're not sure whether you have 32 or 64 bit windows, type this at the prompt:

wmic os get osarchitecture

Aliases for Cygwin (Windows 32-bit)[edit]

If you're using a 32-bit version of windows use this set of instructions.

Let's now add a couple 'aliases' to help you navigate in cygwin.

  • Paste the following lines into the cygwin terminal (you'll probably have to do it one by one). If you've installed notepad++ or Box in a non-default directory, you'll have to modify the pathname. For most people, the code below should work.
cd ~
echo alias e=\""run.exe /cygdrive/c/Program\ Files/Notepad++/notepad++.exe\"" >> .bashrc
echo alias psych711=\""cd /cygdrive/c/Users/$USER/Box\ Sync/Psych711_*/"\" >> .bashrc
alias ls='ls -h --color'
source .bashrc

Aliases for Cygwin (Windows 7 64-bit)[edit]

If you're using Windows 7 64-bit use the instructions below.

  • Paste the following lines into the cygwin terminal (you'll probably have to do it one by one). If you've installed notepad++ or Box in a non-default directory, you'll have to modify the pathname. For most people, the code below should work.
cd ~
echo alias e="\"run.exe /cygdrive/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe"\" >> .bashrc
echo alias psych711=\""cd /cygdrive/c/Users/$USER/Box\ Sync/Psych711_*/"\" >> .bashrc
alias ls='ls -h --color'
source .bashrc

Test Python within Cygwin[edit]

  • Start cygwin and type python.
  • The python interpreter should start and show you that you're using the Enthought version of python.
  • Type exit() to quit python and return to the prompt
  • If python doesn't take you to the python prompt (if it just kind of hangs), hit ctrl -c and do the following:
e ~/.bashrc

This will open up the .bashrc file which contains your cygwin user settings, in Notepad++

You'll want to copy/paste the code below into the bottom of the file.

pythonF() {
	if [ "$#" -gt 0 ]; then
		python $1
	python -i 
alias python=pythonF

Now, save the file, go back to the cygwin prompt and type source ~/.bashrc Try typing in python again, and this time it should take you to the prompt.

Test aliases and psychopy[edit]

  • Type e at the cygwin prompt. This should open up notepad++. To open a file in notepad++ you can just type e and the filename. Handy. Now, go back to the command prompt and type

You should see something trippy. If you're not in the class and so don't have a class Box account, you won't have a file and so won't see anything trippy. Sorry :/ You can test that your psychopy installation is working like so:

$> python
Enthought Canopy Python 2.7.3 | 32-bit | (default, Mar 25 2013, 15:42:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import psychopy
>>> psychopy.__version__

Check if ImageMagick installed properly.[edit]

In a cygwin window type:

convert logo: logo.gif
imdisplay logo.gif

If that opened up an image, you're good to go.

  • You're done.