Using sklearn directly in python from within matlab

I got a solution from the mathworks Support.
It reads the way, that maybe the python environment is not completely setup. I was asked to start matlab from within the Anaconda Prompt which has that complete arranged environment. Running matlab from there yielded the wanted results thus being able to use for example sklearn.
Further comparing the diffenrences from there showed up, that some more directories from python have to be added to the systems search path.

Further I learned, that running py.importlib.import_module(<MODULENAME>) will show details if that python module and its dependencies are available or not.


On a Mac:

  • Open a new terminal window;

  • type: which python (to find out where the default version of python is installed);

  • Restart MATLAB;

  • type: pyversion('/anaconda2/bin/python'), in the command line (obviously replace with your path).
  • You can now run all the libraries in your default python installation.

For example:

>>py.sys.version;

>>py.sklearn.cluster.dbscan