Wow, @Al Danial
Really thank you for your post! It inspired me!
TLDR: the library property can be set by editing matlab.mlsettings particualrily: /fsroot/settingstree/matlab/external/interfaces/python/settings.json
{
"attributes": {
"groupName": "python",
"readonly": false,
"validationFcn": {},
"visible": false
},
"path": "\/settingstree\/matlab\/external\/interfaces\/python",
"settings": [
{
"attributes": {
"readonly": false,
"runtimeDefaultFcn": {},
"settingValueValidator": {},
"validationFcn": {},
"visible": false
},
"hasValue": true,
"isUserDefined": false,
"isVector": true,
"name": "Version",
"value": "{\"mwdata\":[\"3.9\",\"\\\/usr\\\/bin\\\/python3.9\",\"\\\/usr\\\/bin\\\/python3.9\",\"\\\/usr\\\/lib\\\/x86_64-linux-gnu\\\/libpython3.9.so.1\"],\"mwsize\":[1,4],\"mwtype\":\"cell\"}"
}
]
}
Editing "value" to include /usr/lib/x86_64-linux-gnu/libpython3.9.so.1 as Library and /usr/bin/python3.9 as home fixed this issue!
Now calling pyenv yeilds:
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/usr/bin/python3.9"
Library: "/usr/lib/x86_64-linux-gnu/libpython3.9.so.1"
Home: "/usr/bin/python3.9"
Status: NotLoaded
ExecutionMode: InProcess
>> py.print('Printed from Python 3.9!')
Printed from Python 3.9!
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.9"
Executable: "/usr/bin/python3.9"
Library: "/usr/lib/x86_64-linux-gnu/libpython3.9.so.1"
Home: "/usr/bin/python3.9"
Status: Loaded
ExecutionMode: InProcess
ProcessID: "487263"
ProcessName: "MATLAB"
Unfortunately, I don't think this setting can be eddited via the settings api as settings.matlab does not contain an 'external' property. i.e.:
>> s = settings
s =
SettingsGroup with properties:
slhistory: [1×1 SettingsGroup]
matlab: [1×1 SettingsGroup]
Simulink: [1×1 SettingsGroup]
>> s.matlab
ans =
SettingsGroup 'matlab' with properties:
colors: [1×1 SettingsGroup]
appdesigner: [1×1 SettingsGroup]
codeanalyzer: [1×1 SettingsGroup]
toolboxpathcache: [1×1 SettingsGroup]
editor: [1×1 SettingsGroup]
keyboard: [1×1 SettingsGroup]
commandwindow: [1×1 SettingsGroup]
appearance: [1×1 SettingsGroup]
latestgr: [1×1 SettingsGroup]
fonts: [1×1 SettingsGroup]
general: [1×1 SettingsGroup]
So settings.json must be editied manually, I guess.
Finally!