import pylab error - from six import unichr

305 views
Skip to first unread message

Doug Barrett

unread,
Oct 23, 2014, 12:57:30 PM10/23/14
to psychop...@googlegroups.com
Hi,
 
I'm running a stand-alone Psychopy installation (1.81.00) on a Windows 7 machine. I'm trying to plot the coordinates in an numpy.array and cannot import pylab (these will be screen coordinated but I wanted to check them).
 
Here's the code:
 
# Calculate N(x,y) on circumference of a circle
import numpy as np                                  # for maths on arrays
import pylab                                              # see Tutorial 3 for call.
#import matplotlib.pyplot as plt                 # alternate call

# Generate n points around the centre of a circle centred at [0, 0]
def xyLocsCircle(R):
    n = 10                                                    # n locations
    a = 360/n                                               # angle
    ang = np.arange(0, 360, a)                   # vector of angles
    # R = 100                                              # radius
    orig = np.array( [0,0] )                           # origin (x,y)
    # plot x,y coordinates on circumference of a circle (transform angles in degs to radians for np.cos and np.sin functions)
    xyLocs = np.zeros( (2, n) )
    xyLocs[0, ] = [orig[0] + R * np.cos(i) for i in ang * np.pi/180]
    xyLocs[1, ] = [orig[1] + R * np.sin(i) for i in ang * np.pi/180]
    return xyLocs
xy = xyLocsCircle(100)
print xy
pylab.plot(xy[0, ], xy[1, ])
Here's the error:
 
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.81.00-py2.7.egg\psychopy\app\_psychopyApp.py", line 374, in openUpdater
    dlg = connections.InstallUpdateDialog(parent=None, ID=-1, app=self)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.81.00-py2.7.egg\psychopy\app\connections.py", line 246, in __init__
    self.updateStatus()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.81.00-py2.7.egg\psychopy\app\connections.py", line 260, in updateStatus
    msg = _translate("PsychoPy v%(latest)s is available\nYou are running v%(running)s") % {'latest':self.latest['version'], 'running':self.runningVersion}
TypeError: 'NoneType' object has no attribute '__getitem__'
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.81.00-py2.7.egg\psychopy\app\_psychopyApp.py", line 374, in openUpdater
    dlg = connections.InstallUpdateDialog(parent=None, ID=-1, app=self)
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.81.00-py2.7.egg\psychopy\app\connections.py", line 246, in __init__
    self.updateStatus()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.81.00-py2.7.egg\psychopy\app\connections.py", line 260, in updateStatus
    msg = _translate("PsychoPy v%(latest)s is available\nYou are running v%(running)s") % {'latest':self.latest['version'], 'running':self.runningVersion}
TypeError: 'NoneType' object has no attribute '__getitem__'
 
I had a look on stackoverflow and there's a revlevant post at: http://stackoverflow.com/questions/25920510/python-matplotlib-not-importing-due-to-failure-to-import-unichr It's possible the version of six installed is out-of-date (I've got 1.3.0) but I'm not sure how to update this?
 
Any help, much appreciated!
 
Thanks.
 
 

Jeremy Gray

unread,
Oct 23, 2014, 2:57:22 PM10/23/14
to psychop...@googlegroups.com
Hi Doug,

Based on the error (the actual error is: TypeError: 'NoneType' object has no attribute '__getitem__'), this looks like an issue in PsychoPy, and has nothing to do with importing pylab that I can see. (My guess is that self.latest is None, and so self.latest['version'] gives the NoneType error. This should not happen, or the error message should be more helpful than this.)

I suggest trying to start PsychoPy without running your script (e.g., double click the PsychoPy icon), do the update, and then try your script. Hopefully this will avoid trying to display the update dialog window, and avoid that issue.

Also, from the code you posted, the update window should not be displayed. So I am not sure that I understand the full story here.

--Jeremy


--
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/3989e754-a26c-4c94-8b20-fff83726862f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rebecca Sharman

unread,
Oct 24, 2014, 5:31:14 AM10/24/14
to psychop...@googlegroups.com
Hi all,

I'm also having a problem making pylab work in 1.81. I am trying to use plotting scripts that had previously worked so I tried the simplest possible test and typed 'import pylab' into the shell window and it produced the following error.

import pylab
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files (x86)\My81PsychoPy2\lib\site-packages\pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "C:\Program Files (x86)\My81PsychoPy2\lib\site-packages\matplotlib\pylab.py", line 231, in <module>
    import matplotlib.finance
  File "C:\Program Files (x86)\My81PsychoPy2\lib\site-packages\matplotlib\finance.py", line 38, in <module>
    from matplotlib.collections import LineCollection, PolyCollection
  File "C:\Program Files (x86)\My81PsychoPy2\lib\site-packages\matplotlib\collections.py", line 27, in <module>
    import matplotlib.backend_bases as backend_bases
  File "C:\Program Files (x86)\My81PsychoPy2\lib\site-packages\matplotlib\backend_bases.py", line 56, in <module>
    import matplotlib.textpath as textpath
  File "C:\Program Files (x86)\My81PsychoPy2\lib\site-packages\matplotlib\textpath.py", line 22, in <module>
    from matplotlib.mathtext import MathTextParser
  File "C:\Program Files (x86)\My81PsychoPy2\lib\site-packages\matplotlib\mathtext.py", line 26, in <module>
    from six import unichr
ImportError: cannot import name unichr

Generally I'm happy to give a bit of bug fixing a go, but in this case I don't even know where to start! Any ideas gratefully received.

Thanks,
Becky


Doug Barrett

unread,
Oct 24, 2014, 6:22:06 AM10/24/14
to psychop...@googlegroups.com
Hi Jeremy,
 
I've done as you suggested but I don't have the option to update as I'm running the latest version (I only downloaded it a couple of days ago and I've installed v1.81.00). My problem is identical to Rebecca's - when I try "import pylab" I get the idential "ImportError"
 
Thanks, Doug.

Jonathan Peirce

unread,
Oct 27, 2014, 7:55:28 AM10/27/14
to psychop...@googlegroups.com
Apparently pylab requires a newer version of the module called `six` than the version that ships with python. But it's a single file so pretty easy to replace:

Go to the folder
    program files/psychopy2/Lib/site-packages
remove the two files
    six.py and six.pyc
These were six version 1.3.0

Copy into that folder the attached copy of six (v 1.8.0)

I'll make sure I build another full installer with the updated version for the next incremental release.

cheers,
Jon

For more options, visit https://groups.google.com/d/optout.

-- 
Jon Peirce
http://www.peirce.org.uk
six.py

Rebecca Sharman

unread,
Oct 27, 2014, 10:00:33 AM10/27/14
to psychop...@googlegroups.com
Fantastic! Thanks for such an easy fix :)

Cheers,
Becky

Doug Barrett

unread,
Oct 29, 2014, 11:44:00 AM10/29/14
to psychop...@googlegroups.com
Hi John, just-the-job thanks, it's plotting fine now.
 
Doug.
Reply all
Reply to author
Forward
0 new messages