Running MATLAB files/functions in Python (Windows & Anaconda)

October 12, 2022

Install

  1. Make sure Matlab is installed on your computer
  2. Open anaconda prompt as an administrator
  3. Activate the environment you want to use Matlab in
conda activate insert-name-of-environment-here
  1. find the matlab directory
matlab -batch matlabroot

https://www.scivision.dev/matlab-engine-python-install/

  1. cd to that directory
cd C:\Users\Matth>
cd C:\Program Files\MATLAB\R2021a
  1. Run the install script
cd extern/engines/python
python setup.py install
  1. Test to see if it works by opening a Jupyter notebook or Spyder file and run
import matlab.engine