Hi

Ive recently tried to move a python code from a mac version to a version of Psychopy IDE. Now the code wont work on the pc it tells me there a syntax error. Is there something different that mac uses in the python code then the pc? if not any other suggestions why it wouldnt be working


IVe included the code, sadly i didnt write this and no almost nothing about programming

from psychopy import visual, core, misc, event
import numpy #for maths on arrays
from numpy.random import random, shuffle #we only need these two commands from this lib
from random import *
import math

win = visual.Window([1024,768], units='pix', monitor='testMonitor',rgb=(-1,-1,-1))

numbers = range(100) #range of stimuli to be generated or how many to generate

#Choose N, elementsize and filenames

for x in numbers:

    N=85 #number to generate0
    #To choose which stimuli to generate uncomment the appropriate line
    #Contour length
    #elemSize = 2000/((N)*math.pi*2)#contour lentgth
     #elemSize = 2000/((50)*math.pi*2)#50CLcontrol

    #Brightness controls
   # elemSize=math.sqrt(70000/((N)*math.pi))#brightness
    elemSize=math.sqrt(70000/((50)*math.pi))#50BRcontrol

    #create empty list of locations
    locations=[]

    i=1
    while i<=N :
        locations.append([randrange(int(elemSize)-512,512-int(elemSize)),randrange(int(elemSize)-389,389-int(elemSize))])
        i=i+1
                
     #build an array of circles according to the parameters
    globForm = visual.ElementArrayStim(win, nElements=N, units='pix',sizes=elemSize,fieldShape='sqr',fieldSize=(1024-elemSize,768-elemSize),sfs=0,elementMask='circle',xys=locations)
    
    globForm.draw()
    win.flip(clearBuffer=False)#redraw the buffer
    win.getMovieFrame()
    win.flip(clearBuffer=True)

#adjustfilename as appropriate
win.saveMovieFrames('B085.jpg')
core.quit()
event.clearEvents()#keep the event buffer from overflowing

Recommended Answers

All 8 Replies

What is your error message?
Do you have the module psychopy and module numpy installed on your PC's version of Python? These two modules do not normally come with the Python installation, and have to be downloaded separately.

Running C:\Documents and Settings\Administrator\Desktop\NumberStudyMaterials\NumberStimuliGenerator(revised).py
Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.pyc", line 460, in __bootstrap
File "PsychoPyIDE.py", line 181, in __run
File "threading.pyc", line 440, in run
File "PsychoPyIDE.py", line 1687, in _runFileAsImport
File "<string>", line 1
import NumberStimuliGenerator(revised)
^
SyntaxError: invalid syntax


and no ive never heard of those two programs you mentioned do i have to install them for it to run on windows?

Also, when i import things i get a syntax error if i have brackets in my import. So that might be it, seeing as it looks like its trying to import
NumberStimuliGenerator(revised). Personally i would change the file's name to something without brackets. Seeing as in python, they usually mean a tuple or function!

Hope that helps

ok well that did something the error message i get is different now. Though i am comfused this code worked on the mac i used and now that im trying to use it on a pc it giving me errors.


Running C:\Documents and Settings\Administrator\Desktop\NumberStudyMaterials\NumberStimuliGenerator revised.py
Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.pyc", line 460, in __bootstrap
File "PsychoPyIDE.py", line 181, in __run
File "threading.pyc", line 440, in run
File "PsychoPyIDE.py", line 1687, in _runFileAsImport
File "<string>", line 1
import NumberStimuliGenerator revised
^
SyntaxError: unexpected EOF while parsing

Since there is a file NumberStimuliGenerator(revised).py

import NumberStimuliGenerator(revised)

should be allowed!?

Never used () or a space in a module name on Windows.

well so far we hacking at it, i didnt notice i left a space in the name. So its will run the program now but i get this now. thanks guys for the help so far


Running C:\Documents and Settings\Administrator\Desktop\NumberStudyMaterials\NumberStimuliGeneratorrevised.py
configured pyglet screen 0
Exception in thread Thread-3:
Traceback (most recent call last):
File "threading.pyc", line 460, in __bootstrap
File "PsychoPyIDE.py", line 181, in __run
File "threading.pyc", line 440, in run
File "PsychoPyIDE.py", line 1687, in _runFileAsImport
File "<string>", line 1, in <module>
File "C:\Documents and Settings\Administrator\Desktop\NumberStudyMaterials\NumberStimuliGeneratorrevised.py", line 36, in <module>
File "psychopy\visual.pyc", line 2519, in draw
AttributeError: Window instance has no attribute '_progSignedTexMask'

Well, a quick test shows that Python does not allow () or spaces in module names. You should be able to use an underscore _ character.

ok the name wasnt a big deal anyway. So is there any reason why when used on a mac there was no problem?


can anyone help me with this error code now?

AttributeError: Window instance has no attribute '_progSignedTexMask'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.