Installing Matlab Engine to Psychopy

Hello,

Is it possible to install the Matlab engine (see link below) to psychopy? And has anyone done this before?

http://uk.mathworks.com/help/matlab/matlab-engineforpython.html?requestedDomain=www.mathworks.com

The engine allows you to call Matlab methods from within python and access information from Matlab variables via it’s work-space etc. in Python itself. I have installed the engine fine with my normal Python 2.7 via:

cd "matlabroot\extern\engines\python"
python setup.py install

This way I was able to ‘import matlab.engine’ and use it perfectly well. I expected to open up Psychopy and import etc. right away but I’m getting the error:

ImportError: No module named matlab.engine.

I would like to know how to install this to Psychopy itself.

Thanks,

Steve

PsychoPy comes with it’s own bundle of python on Windows and Mac but uses a system-wide python on Linux. I presume that you’re using Mac or Windows, so you installed matlab.engine on another install of python than the one that psychopy uses. And so, when running from Coder, you cannot import that module.

There’s two solutions:

  1. Install matlab.engine into psychopy’s python as described in the documentation: http://www.psychopy.org/recipes/addCustomModules.html

  2. Windows-only: start an editor on your system-wide python and set psychopy’s modules in your PYTHON_PATH. That’s what I do and I wrote a guide for Spyder: http://lindeloev.net/?page_id=216

@Steve1, did you solve your problem (and how)? We and future users will be interested to hear your feedback!

I decided to abandon this route altogether so I cannot currently offer any feedback with respect to this, apologies.

How can I use psychopy codes which related to the task that I created in the matlab? I mean how can I convert them?