psychopy.org | Reference | Downloads | Github

Experiment does not run in PsychoPy3 v3.2.4

The code written in Psychopy v1.85.6 does not work in the new version PsychoPy3 v3.2.4.
I get an error
line 27, in
random.shuffle(stimlist)

File “D:\psychopyinstall\lib\random.py”, line 274, in shuffle
for i in reversed(range(1, len(x))):
TypeError: object of type ‘zip’ has no len()

I also want to create a virtual environment for PsychoPy so that I won’t have version problems, but I do not know how to do it, I would appreciate it if you can give me some information about how to do it.

Thank you…
Asli

Hi @asli, this is actually a Python 2 vs Python 3 difference. To fix, try:

for i in reversed(range(1, len(list(x)))):
    # do stuff 

Alternatively, if you want to stick with Python 2, install the Python version of Psychopy.

Hi @dvbridges ,
Thank you for your answer,

First could you guide us in how to create a virtual environment for PsychoPy, so to overcome version problems,
Also related to your solution

I have Python3 version 3.7.3
and PsychoPy3 v3.2.4
The code was written in an earliear version of Psychopy - v1.85.6, therefore as you mentioned we are having these problems due to version differences.

When I changed the code
for i in reversed(range(1, len(list(x)))):

I get this new error due to random.py

File “D:\psychopyinstall\lib\random.py”, line 277, in shuffle
x[i], x[j] = x[j], x[i]
TypeError: ‘zip’ object is not subscriptable

the error is related to the code in line 27, in random.shuffle(stimlist)

stimlist=zip(respCond2, probDot2)
random.shuffle(stimlist)

Thank you…
Asli