PyGaze icon indicating copy to clipboard operation
PyGaze copied to clipboard

Move to Python 3.x and 64 bit?

Open arnohakk opened this issue 5 years ago • 10 comments

Hey,

when just reinstalling our system, Python 2.7 told me that it is getting towards the end of its life cycle.

As a Tobii User, I found that the new SDK supports Python 3.X and 64bit systems, same holds true for PsychoPy. I don't know about the other manufactures SDKs though.

@esdalmaijer Do you think about migrating to Python 3.X 64 bit? I think we (with the help of Tobii, who are usually interested in giving researchers this kind of support) could help from the Tobii SKD side and also do some testing.

Cheers,

Arne

arnohakk avatar Jun 06 '19 16:06 arnohakk

Hi Arne,

There isn't a day that I don't think asbout it. (Usually after waking up from a stress dream that includes the Python clock.)

In fact, @jooh made a first stab at it a while back (see this pull request. From local testing by colleagues, this seems to work, at least with EyeLink.

I haven't found the time to properly focus on this, but applaud and am happy to support any thorough attempt. In general, there shouldn't be a lot that isn't currently compatible with Python 3, I think. However, going over the whole codebase to double-check, and even checking the whole codebase after an automated pass-through, will probably be quite a bit of work,

Cheers, Edwin

esdalmaijer avatar Jun 07 '19 13:06 esdalmaijer

Hi Edwin,

Maybe if you split up the codebase, a couple of people can do a part of the manual checking? I volunteer to do a part. Is the opensesame plugin part already py3 compatible?

Cheers, Bob

dev-jam avatar Jul 01 '19 19:07 dev-jam

The time is now... https://www.python.org/doc/sunset-python-2/

lorenzleutgeb avatar Sep 13 '19 08:09 lorenzleutgeb

Hey, I just saw that there was an update to Python3 :) What do I have to consider when moving to this new version, e.g. dependencies?

arnohakk avatar Jan 22 '20 14:01 arnohakk

Yassss, we finally did it! Sorry it took a while, this ended up being more effort than I had hoped, especially when having to test on various platforms. Specific dependencies below.

TL;DR: Your Python 2 code should work on Python 3 as far as PyGaze functions go. Obviously you'll have to make sure that Python-specific things are converted (e.g. raw_input to input), but PyGaze shouldn't give you any grief.

  • Python 3, obviously.
  • PyGame: Totally fine to simply hop onto the PyGame version for Python 3 without issue. I love this package so much.
  • PsychoPy: Fine in general, but I haven't been able to install one of its dependencies (pywinhook) on Windows. Not sure why, but it simply fails to install through pip and conda. It doesn't seem to affect anything in PyGaze, though. (As in: I've not yet found anything that depended on it.)
  • PsychoPy dependencies: After installing Anaconda3 and then PsychoPy, it didn't run out of the box for me. I had to update pillow, numpy, scipy, and matplotlib. Not sure why, not sure how general this problem is; my issues appeared on Win7 and later on Win10 in a conda environment (but some of that was to do with conda specifically; I ended up using only pip to reinstall everything, and that worked out nicely).
  • lxml: You'll need this for OpenGaze (==GazePoint). The Python 3 version works without issue.
  • pylink: You'll need this for EyeLink. You'll have to ask for the Python 3 pylink version from SR Research directly (they didn't have one publicly available when we were starting to move over near the end of last year; they might do now?). This will be version 1.11, which might or might not be newer than you're used to. This caused some issue in PyGaze's streaming of the eye image in the calibration setup to the stimulus PC, which has been resolved in the update to Python 3. (We now test if you're using pylink 1.11 or higher, and change our drawing routine based on that. If you see a crosshair that doesn't accurately pinpoint pupil and glint, please tell me.)
  • PyOpenGaze, PyTribe, and PyAlea: These are Python libraries I develop and maintain for GazePoint, EyeTribe, and Alea eye trackers. All of these are already included within PyGaze, and thus ready to be used in Python 3.
  • Tobii: tobii_research is available from Tobii, also for Python 3. I don't think there's any difference from a user's perspective for Python 3, but I haven't been able to properly test this.
  • SMI: I've updated the SMI code in PyGaze, so things should work in Python 3 (the ctypes interaction required a wee bit of work). This simply wraps a DLL that shouldn't be affected by Py2 vs. 3).

PS: Don't update a working experiment! If you're still collecting data, wait with changing stuff until you're finished! Also, Python 3 can exist alongside Python 2, either as local installs or as conda environments. So I would strongly recommend trying to get your Python 3 environment up and running alongside your currently running Python 2 environment.

esdalmaijer avatar Jan 22 '20 15:01 esdalmaijer

Oh, I forgot to mention! There is still a Python 2.7 snapshot that people can still contribute to if they find any bugs. It's in a branch called python27: https://github.com/esdalmaijer/PyGaze/tree/python27

If you're wanting to install this older snapshot in a Python 2 environment, simply run: pip install python-pygaze=0.6.5

esdalmaijer avatar Jan 22 '20 15:01 esdalmaijer

I'm planning on getting started with this sometime this week and while I do have conda setup I'd strongly prefer to use everything with with Python3 (as python 2 is now EOL). After skimming above seems to be at a reasonable stage.

  1. How would I go by trying to install this for Tobii 4c, Ubuntu 18.04, Python3? What should my 'requirements.txt' look like?

harsh183 avatar Feb 19 '20 18:02 harsh183

The same as for Python 2, essentially :)

Generally: pip install numpy scipy matplotlib pillow

Add PyGame: pip install pygame

Add PsychoPy and its dependencies: pip install psychopy

If you're wanting to use a GazePoint tracker: pip install lxml

And for Tobii: pip install tobii_research

For EyeLink, there is a Python3 version of pylink available, but you'll have to request it from SR Research. (Their support forum is a great venue to do so, and I think they might even have it available directly through there. You'll have to make an account, but it's free.)

The one point you should consider with Tobii, is that tobii_research currently only supports Python 3.5. See: https://pypi.org/project/tobii-research/

esdalmaijer avatar Feb 20 '20 02:02 esdalmaijer

Should I setup some conda or virtual env for this then? I'm using the Tobii 4c and Ubuntu 18.04.

Can you put this on the main website or documentation somewhere since I felt all the instructions are made with Python2 in mind?

I will setup the following after making sure I am on python==3.5

  1. pip install numpy scipy matplotlib pillow
  2. pip install pygame
  3. pip install psychopy
  4. pip install tobii_research

Will there be any other pieces of setup I have to do?

harsh183 avatar Feb 21 '20 02:02 harsh183

The one point you should consider with Tobii, is that tobii_research currently only supports Python 3.5. See: https://pypi.org/project/tobii-research/

In fact Tobii-research also supports 3.6.0. as I just was informed by the Tobii support. The information on PyPi is probably not updated. I tried it out under 3.6.0 and it works. Maybe this helps people with the same issue as me wondering how PsychoPy and Tobii-research can work together if the support different Python versions.

Sme1d avatar May 14 '20 08:05 Sme1d