Psychopy 2021.2.3-1 fails to start

I recently upgraded to Python 3.10.2 on Arch Linux and now Psychopy 2021.2.3-1 crashes on start up with:

  ...
  File "/usr/lib/python3.10/site-packages/macropy/activate.py", line 4, in <module>
    macropy.activate()
  File "/usr/lib/python3.10/site-packages/macropy/__init__.py", line 18, in activate
    from .core import hquotes  # noqa
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 945, in _find_spec
  File "/usr/lib/python3.10/site-packages/macropy/core/import_hooks.py", line 147, in find_spec
    code, tree = self.expand_macros(source, origin, spec)
  File "/usr/lib/python3.10/site-packages/macropy/core/import_hooks.py", line 113, in expand_macros
    return compile(tree, filename, "exec"), new_tree
TypeError: required field "lineno" missing from alias

I am running macropy version 1.1.0b2 and import macropy.activate gives the same error. This seems to be the latest version of macropy, but there is a bug report from a year ago that macropy does not work with Python 3.8+. I am pretty sure I used Psychopy with Python 3.8 and 3.9, so I am lost.

I feel like I am missing something obvious.

Is this the standalone version installed from PsychoPy.org?

No, it is essentially an install built from the 2021.2.3 source tarball (https://github.com/psychopy/psychopy/archive/2021.2.3.tar.gz) using python setup.py install

Looking into it more, my guess is it is related to the fact that the recommended Python version is 3.6 (which is now past end of life) and that 3.10 is just not supported. I am installing now into a virtual environment with Python 3.9 and checking to see if PsychoPy will pass all the unit tests.

Hi @daniel.e.shub and @Becca,

Is there any news related to this error message?

I managed to install PsychoPy on Ubuntu 22.04 without any errors (i.e. satisfying all dependencies) but, when I try to run it, nothing happens.

The contents of last_app_load.log is this:

Error while compiling file /home/flavio/.local/lib/python3.10/site-packages/macropy/core/hquotes.py
Traceback (most recent call last):
File “/home/flavio/.local/lib/python3.10/site-packages/macropy/core/import_hooks.py”, line 113, in expand_macros
return compile(tree, filename, “exec”), new_tree
TypeError: required field “lineno” missing from alias
Traceback (most recent call last):
File “/home/flavio/.local/bin/psychopy”, line 8, in
sys.exit(main())
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/app/psychopyApp.py”, line 98, in main
start_app()
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/app/psychopyApp.py”, line 26, in start_app
app = startApp(showSplash=showSplash)
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/app/init.py”, line 84, in startApp
from psychopy.app._psychopyApp import PsychoPyApp
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/app/_psychopyApp.py”, line 21, in
from . import themes
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/app/themes/init.py”, line 1, in
from ._themes import ThemeMixin, IconCache
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/app/themes/_themes.py”, line 18, in
from …experiment import components
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/experiment/init.py”, line 19, in
from .params import getCodeFromParamStr, Param
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/experiment/params.py”, line 25, in
from . import py2js
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/experiment/py2js.py”, line 21, in
from psychopy.experiment.py2js_transpiler import translatePythonToJavaScript
File “/home/flavio/.local/lib/python3.10/site-packages/psychopy/experiment/py2js_transpiler.py”, line 13, in
from metapensiero.pj.api import translates
File “/home/flavio/.local/lib/python3.10/site-packages/metapensiero/pj/api.py”, line 21, in
from . import transformations
File “/home/flavio/.local/lib/python3.10/site-packages/metapensiero/pj/transformations/init.py”, line 11, in
import macropy.activate
File “/home/flavio/.local/lib/python3.10/site-packages/macropy/activate.py”, line 4, in
macropy.activate()
File “/home/flavio/.local/lib/python3.10/site-packages/macropy/init.py”, line 18, in activate
from .core import hquotes # noqa
File “”, line 1027, in _find_and_load
File “”, line 1002, in _find_and_load_unlocked
File “”, line 945, in _find_spec
File “/home/flavio/.local/lib/python3.10/site-packages/macropy/core/import_hooks.py”, line 147, in find_spec
code, tree = self.expand_macros(source, origin, spec)
File “/home/flavio/.local/lib/python3.10/site-packages/macropy/core/import_hooks.py”, line 113, in expand_macros
return compile(tree, filename, “exec”), new_tree
TypeError: required field “lineno” missing from alias
0.1405 DEBUG Opening message catalog /home/flavio/.local/lib/python3.10/site-packages/psychopy/localization/…/app/locale/pt_BR/LC_MESSAGE/messages.mo for locale pt_BR
0.1406 DEBUG Locale for ‘pt_BR’ not found. Using default.

I’m working on a “how to”, but got stuck there.
I appreciate any guesses/clues/pointers :slightly_smiling_face:

I can get past the macropy issue (What is the state of Python 3.10 support? - #2 by jon) by using the unreleased version of javascripthon (metapensiero.pj/CHANGES.rst at master · metapensiero/metapensiero.pj · GitHub) that does not depend on macropy. I still cannot get the newest versions of PsychoPy to run on Linux with Python 3.10.

Hey Daniel, I saw your tip on the Github issue. Thanks so much. I was able to get past that error, then ran into some issues with wxPython. I built a source wheel, which was necessary the last time I tried this, for some reason I’ve forgotten:

 pip install -U \
    -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 \
    wxPython

Then came the horrible part: I had to go through some of the PsychoPy and WxPython files and make some manual changes to do with wx functions no longer accepting float values. I just wrapped all offending expressions in int(...) and replaced real divisions with integer division (i.e. x /= 2x //= 2).
I should probably try to generate a diff, but I just edited them in place and kept relaunching until it worked.
The files that needed changing were:

~/.local/lib/python3.10/site-packages/wx/lib/agw/aui/auibook.py
~/.local/lib/python3.10/site-packages/wx/lib/agw/aui/tabart.py
~/.local/lib/python3.10/site-packages/wx/lib/agw/advancedsplash.py
~/.local/lib/python3.10/site-packages/psychopy/app/builder/builder.py
~/.local/lib/python3.10/site-packages/psychopy/app/psychopyApp.py

Hope this helps. If you have more trouble let me know and I’ll take another look.

I have no idea how anyone has gotten PsychoPy to work with Python 3.10. The issue is not wx, but a change in Python (Issue 37999: No longer use implicit convertion to int with loss - Python tracker). The changes you made to the wx files (and then some) are probably already available upstream (Fix a bunch of Python 3.10 issues with pure-Python classes and demos · wxWidgets/Phoenix@173d079 · GitHub) but not released yet.

You should definitely report the bug (or a PR) on Git. A diff would be helpful. My concern is that these issues are hidden in sections of code not covered by starting the app or the unit tests.

I see. Well, PsychoPy is working for me fine now in Python 3.10 with those changes, although I’m only using it for one existing program. It was a faff though, and I was tempted to give up halfway through.

[edit]
Looking at that Python issue, that really does seem like a huge breaking change. I’m surprised there wasn’t more discussion on the issue.