Installing Matlab Python API (Mac)

179 views Asked by At

I've got Python 3.9 (thru Anaconda) and Matlab R2021b installed on my Mac (Monterey). It is my personal computer, so I should have full administrator privileges. In following the instructions here, I ran open .bash_profile and found that when setting up Anaconda it had added the following:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('~/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "~/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "~/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="~/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

so that the Python interpreter should indeed be in-PATH (?). Then, in the Matlab terminal I found that my matlabroot is /Applications/MATLAB_R2021b.app so I ran

cd /Applications/MATLAB_R2021b.app/extern/engines/python
python setup.py install

without (I think) any issues. Back in Matlab, I ran

cd (fullfile(matlabroot,'extern','engines','python'))
system('python setup.py install')

but was met with

...
running install_lib
creating /Library/Python
error: could not create '/Library/Python': Permission denied

(the ... are other, presumably successful, copy operations, which I can add back if it would be helpful).

I'm very uncomfortable working with filesystem stuff and don't understand too well how to debug/navigate these kinds of issues, so any help with getting the Matlab API up and running would be enormously helpful. Thanks in advance.

0

There are 0 answers