ImportError: sys.meta_path is None, Python is likely shutting down

If this template helps then use it. If not then just delete and start from scratch.

macOS Mojave 10.14.16
PsychoPy 2020.2.10

The same problem occurs every time I start to type an answer using TextBox. I tried to delete PsychoPy and start again, but this didn’t help.

`Exception ignored in: <bound method TextStim.__del__ of <psychopy.visual.text.TextStim object at 0x1585e65f8>>
Traceback (most recent call last):
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/visual/text.py", line 240, in __del__
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/gl/lib.py", line 99, in errcheck
ImportError: sys.meta_path is None, Python is likely shutting down

I also use a levenshtein function, but coder says that there’s a syntax error, but I believe that the code is alright:

def levenshtein_ratio_and_distance(s, t, ratio_calc = False):
    rows = len(s)+1
    cols = len(t)+1
    distance = np.zeros((rows,cols),dtype = int)
    for i in range(1, rows):
        for k in range(1,cols):
            distance[i][0] = i
            distance[0][k] = k
    for col in range(1, cols):
        for row in range(1, rows):
            if s[row-1] == t[col-1]:
                cost = 0 # If the characters are the same in the two strings in a given position [i,j] then the cost is 0
            else:
                if ratio_calc == True:
                    cost = 2
                else:
                    cost = 1
            distance[row][col] = min(distance[row-1][col] + 1, distance[row][col-1] + 1, distance[row-1][col-1] + cost)     # Cost of substitutions
    if ratio_calc == True:
        Ratio = ((len(s)+len(t)) - distance[row][col]) / (len(s)+len(t))
        return Ratio
    else:
        return distance[row][col]

How can I possibly solve it? The error shows up every time (whether I’m typing or not).

For this error, can you please try using version 2021.1.0, released yesterday. It fixes several places in the code that were generating this error. Hopefully it also fixes it in your case, otherwise please let us know.

Please include the actual error you are getting when possible.

Are you calling import numpy as np somewhere earlier in your script? That is the only error I see in the code fragment you included.

Thank you so much! I downloaded the latter version and ran my experiment and now i get this error: `

TypeError: ‘<’ not supported between instances of ‘NoneType’ and ‘int’
Traceback (most recent call last):
File "ctypes/callbacks.c", line 234, in ‘calling callback function’
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/libs/darwin/cocoapy/runtime.py”, line 1128, in objc_method
result = f(py_self, *args)
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/window/cocoa/pyglet_view.py”, line 199, in pygletKeyDown
self._window.dispatch_event(‘on_key_press’, symbol, modifiers)
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/window/init.py”, line 1333, in dispatch_event
if EventDispatcher.dispatch_event(self, *args) != False:
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/event.py”, line 422, in dispatch_event
self._raise_dispatch_exception(event_type, args, getattr(self, event_type), exception)
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/event.py”, line 476, in _raise_dispatch_exception
raise exception
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/event.py”, line 415, in dispatch_event
if getattr(self, event_type)(*args):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/visual/backends/pygletbackend.py”, line 376, in onKey
thisKey = pyglet.window.key.symbol_string(evt).lower()
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/window/key.py”, line 145, in symbol_string
if symbol < 1 << 32:
TypeError: ‘<’ not supported between instances of ‘NoneType’ and ‘int’

I don’t use import numpy as np anywhere earlier in the experiment.

I don’t use import numpy as np anywhere earlier in the experiment.

That explains that issue then, it needs to be added or your refence to np needs to change to numpy.

Re the new exception:

File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/visual/backends/pygletbackend.py”, line 376, in onKey
thisKey = pyglet.window.key.symbol_string(evt).lower()
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/pyglet/window/key.py”, line 145, in symbol_string
if symbol < 1 << 32:
TypeError: ‘<’ not supported between instances of ‘NoneType’ and ‘int’

Could you provide a complete but minimal example that reproduces the error?

Thank you.