| Reference | Downloads | Github

Installing and using sklearn module in psychopy

Hi all, I’ve been having the most difficult time getting PsychoPy (v1.85.6) to successfully import from sklearn. On OSX I had no problem adding a path in PsychoPy’s preferences so that it could find the module in my Anaconda installation. However, now that I’m trying to run my program on a PC with Windows 7, I’m having no luck at all. I’ve tried adding paths to the preferences like I did on my Mac, but I get the following error:

Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\lab\Anaconda2\Lib\site-packages\sklearn\”, line 15, in
from .least_angle import (Lars, LassoLars, lars_path, LarsCV, LassoLarsCV,
File “C:\Users\lab\Anaconda2\Lib\site-packages\sklearn\linear_model\”, line 23, in
from …utils import arrayfuncs, as_float_array, check_X_y, deprecated
ImportError: DLL load failed: The specified module could not be found.

I’ve also tried installing directly to the PsychoPy site-packages directory with:

pip install --target=“C:\Program Files (x86)\PsychoPy2\Lib\site-packages” scikit-learn

But then when I try to load sklearn in PsychoPy, I get the following error:

Traceback (most recent call last):
File “”, line 1, in
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\”, line 133, in
from . import __check_build
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\”, line 46, in
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\”, line 41, in raise_build_error
%s""" % (e, local_dir, ‘’.join(dir_content).strip(), msg))
ImportError: No module named _check_build

Contents of C:\Program Files (x86)\PsychoPy2\lib\site-packages\sklearn_check_build: check_build.cp36-win_amd64.pyd__init
init.pyc pycache

It seems that scikit-learn has not been built correctly.

If you have installed scikit-learn from source, please do not forget
to build the package before using it: run python install or
make in the source directory.

If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.

I’m still fairly new to python and psychopy, but as far as I can tell, I’m following all the directions I can find online correctly. Does anyone have any thoughts on how to solve this?

Thanks in advance!

Hi, you might have better luck installing PsychoPy into your Anaconda installation, then it is in the same place as any other packages you install.

Switch to an Anaconda environment and then simply pip install psychopy to get most of what you need.