psychopy.org | Reference | Downloads | Github

ImportError: DLL load failed: The specified module could not be found

I tried a simple builder experiment and when I run nothing happens, so I tried to run in tried to run in the equivalent coder of the builder experiment which is:
‘’
This experiment was created using PsychoPy3 Experiment Builder (v3.0.5),
on fevereiro 25, 2019, at 18:12
If you publish work using this script please cite the PsychoPy publications:
Peirce, JW (2007) PsychoPy - Psychophysics software in Python.
Journal of Neuroscience Methods, 162(1-2), 8-13.
Peirce, JW (2009) Generating stimuli for neuroscience using PsychoPy.
Frontiers in Neuroinformatics, 2:10. doi: 10.3389/neuro.11.010.2008
“”"

from future import absolute_import, division
from psychopy import locale_setup, sound, gui, visual, core, data, event, logging, clock
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)
import numpy as np # whole numpy lib is available, prepend ‘np.’
from numpy import (sin, cos, tan, log, log10, pi, average,
sqrt, std, deg2rad, rad2deg, linspace, asarray)
from numpy.random import random, randint, normal, shuffle
import os # handy system and path functions
import sys # to get file system encoding

Ensure that relative paths start from the same directory as this script

_thisDir = os.path.dirname(os.path.abspath(file))
os.chdir(_thisDir)

Store info about the experiment session

psychopyVersion = ‘3.0.5’
expName = ‘demo1’ # from the Builder filename that created this script
expInfo = {‘participant’: ‘’, ‘session’: ‘001’}
dlg = gui.DlgFromDict(dictionary=expInfo, title=expName)
if dlg.OK == False:
core.quit() # user pressed cancel
expInfo[‘date’] = data.getDateStr() # add a simple timestamp
expInfo[‘expName’] = expName
expInfo[‘psychopyVersion’] = psychopyVersion

Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc

filename = thisDir + os.sep + u’data/%s%s_%s’ % (expInfo[‘participant’], expName, expInfo[‘date’])

An ExperimentHandler isn’t essential but helps with data saving

thisExp = data.ExperimentHandler(name=expName, version=’’,
extraInfo=expInfo, runtimeInfo=None,
originPath=‘C:\Users\Li\Desktop\Python_Exercises\demo1_lastrun.py’,
savePickle=True, saveWideText=True,
dataFileName=filename)

save a log file for detail verbose info

logFile = logging.LogFile(filename+’.log’, level=logging.EXP)
logging.console.setLevel(logging.WARNING) # this outputs to the screen, not a file

endExpNow = False # flag for ‘escape’ or other condition => quit the exp

Start Code - component code to be run before the window creation

Setup the Window

win = visual.Window(
size=(1024, 768), fullscr=True, screen=0,
allowGUI=False, allowStencil=False,
monitor=‘testMonitor’, color=[0,0,0], colorSpace=‘rgb’,
blendMode=‘avg’, useFBO=True,
units=‘height’)

store frame rate of monitor if we can measure it

expInfo[‘frameRate’] = win.getActualFrameRate()
if expInfo[‘frameRate’] != None:
frameDur = 1.0 / round(expInfo[‘frameRate’])
else:
frameDur = 1.0 / 60.0 # could not measure, so guess

Initialize components for Routine “welcome_screen”

welcome_screenClock = core.Clock()
textWelcome = visual.TextStim(win=win, name=‘textWelcome’,
text=‘Welcome please read the instructions’,
font=‘Arial’,
pos=(0, 0), height=0.1, wrapWidth=None, ori=0,
color=‘white’, colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=0.0);

Create some handy timers

globalClock = core.Clock() # to track the time since experiment started
routineTimer = core.CountdownTimer() # to track time remaining of each (non-slip) routine

------Prepare to start Routine “welcome_screen”-------

t = 0
welcome_screenClock.reset() # clock
frameN = -1
continueRoutine = True

update component parameters for each repeat

keyWelcome = event.BuilderKeyResponse()

keep track of which components have finished

welcome_screenComponents = [textWelcome, keyWelcome]
for thisComponent in welcome_screenComponents:
if hasattr(thisComponent, ‘status’):
thisComponent.status = NOT_STARTED

-------Start Routine “welcome_screen”-------

while continueRoutine:
# get current time
t = welcome_screenClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame

# *textWelcome* updates
if t >= 0.0 and textWelcome.status == NOT_STARTED:
    # keep track of start time/frame for later
    textWelcome.tStart = t
    textWelcome.frameNStart = frameN  # exact frame index
    textWelcome.setAutoDraw(True)

# *keyWelcome* updates
if t >= 0 and keyWelcome.status == NOT_STARTED:
    # keep track of start time/frame for later
    keyWelcome.tStart = t
    keyWelcome.frameNStart = frameN  # exact frame index
    keyWelcome.status = STARTED
    # keyboard checking is just starting
    win.callOnFlip(keyWelcome.clock.reset)  # t=0 on next screen flip
    event.clearEvents(eventType='keyboard')
if keyWelcome.status == STARTED:
    theseKeys = event.getKeys(keyList=['y', 'n', 'left', 'right', 'space'])
    
    # check for quit:
    if "escape" in theseKeys:
        endExpNow = True
    if len(theseKeys) > 0:  # at least one key was pressed
        keyWelcome.keys = theseKeys[-1]  # just the last key pressed
        keyWelcome.rt = keyWelcome.clock.getTime()
        # a response ends the routine
        continueRoutine = False

# check for quit (typically the Esc key)
if endExpNow or event.getKeys(keyList=["escape"]):
    core.quit()

# check if all components have finished
if not continueRoutine:  # a component has requested a forced-end of Routine
    break
continueRoutine = False  # will revert to True if at least one component still running
for thisComponent in welcome_screenComponents:
    if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
        continueRoutine = True
        break  # at least one component has not yet finished

# refresh the screen
if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
    win.flip()

-------Ending Routine “welcome_screen”-------

for thisComponent in welcome_screenComponents:
if hasattr(thisComponent, “setAutoDraw”):
thisComponent.setAutoDraw(False)

check responses

if keyWelcome.keys in [’’, [], None]: # No response was made
keyWelcome.keys=None
thisExp.addData(‘keyWelcome.keys’,keyWelcome.keys)
if keyWelcome.keys != None: # we had a response
thisExp.addData(‘keyWelcome.rt’, keyWelcome.rt)
thisExp.nextEntry()

the Routine “welcome_screen” was not non-slip safe, so reset the non-slip timer

routineTimer.reset()

these shouldn’t be strictly necessary (should auto-save)

thisExp.saveAsWideText(filename+’.csv’)
thisExp.saveAsPickle(filename)
logging.flush()

make sure everything is closed down

thisExp.abort() # or data files will save again on exit
win.close()
core.quit()
‘’
and the following errors appear:
"

######## Running: C:\Users\Li\Desktop\Python_Exercises\demo1_lastrun.py ########
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\gui\qtgui.py”, line 15, in
from PyQt4 import QtGui
ModuleNotFoundError: No module named ‘PyQt4’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\Li\Desktop\Python_Exercises\demo1_lastrun.py”, line 14, in
from psychopy import locale_setup, sound, gui, visual, core, data, event, logging, clock
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\gui_init_.py”, line 33, in
from .qtgui import *
File “C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\gui\qtgui.py”, line 19, in
from PyQt5 import QtWidgets
ImportError: DLL load failed: Impossível localizar o procedimento especificado.
"

OS Win7
PsychoPy version: latest version
Do you have any idea how to fix this? Thank you

Hi @mariafrancisca496, this issue has been raised on GitHub. Perhaps Jons quick fix on there will work:

Hello,
I already tried to put the C:\Program Files (x86)\PsychoPy3\DLLs in my path and it didn’t work. I really don’t know what can be the problem, thanks for your response btw.

Ok, apologies for the inconvenience. Jon is on the case, so best to keep your eye on the GitHub issue.

1 Like