psychopy.org | Reference | Downloads | Github

Paving the way for Python3

python3

#1

Just to let you know about progress towards Python3:

Version 1.85.3 has just been released and it introduces new dependencies on the following packages:

  • future is now needed to allow dual compatibility with Python2.7 and Python 3.6 (not sure about 3.5). We will hopefully allow both versions to be supported for some time (a year maybe?) and Standalone packages will be built for 3.6 and 2.7, for a period, so that users can choose which to use
  • json_tricks was needed because monitor calibration files (which were pickle format) from 2.7 won’t load in 3.6 as far as I know. In future we’ll save calibrations as JSON format files but this package is needed in order to dump/load numpy arrays and date structures (the built-in json lib doesn’t handle those). For a period PsychoPy running on 2.7 will load files from calib (pickle) files but will immediately save them as json files as well. Python3 instances will only attempt to load/save json files.

There are still going to be areas of broken functionality for Python3 and it would be great to see people using it and finding the issues. You can get started really easily:

  • install Python3 from python.org
  • cd into your psychopy repository
  • do pip3 install . -e to get a development install including all the dependencies!

have fun
Jon


#2

I updated my PsychoPy projects to use Python 3.6, appears to be seamless given the recommendations above.

One feature I like in 3.6 is the matrix multiplication infix operator ‘@’ (PEP 465). Some of the matrix math is a bit messy at this point, having it will aid in moving away from fixed function OpenGL.


#3

pip install future fixes the ImportError: No module named builtins when trying to launch PsychoPy for anyone like me who has not yet upgraded their development environment from 2.7 (apparently due to builtin being renamed to builtins in Python 3).


#4

pip install future did not clear this up for me (still on python 2.7.14), I still get ImportError: No module named builtins. Any hints how to proceed? Just switch over to python 3.6?

(I have been away from the project for far too long!)


#5

Are you sure that future got installed to the correct python installation?

Unless you need hardware interfaces like eye tracking then yes I would recommend you switch to python 3.6. It does have lots of nice things (e.g. check out the new system for formatted strings)


#6

thanks yeah, that was it. I have an unholy mix of old Enthought installs (which have pythonw) and newer conda installs (that apparently don’t have pythonw). Time to clean up a bit!


#7

Maybe you need to install the ‘past’ package? Try:

pip install past (I know, pretty silly it’s setup like this)