Python is recognised in MATLAB but basic functions are not working

2 次查看(过去 30 天)
I'm Having a wierd problem with my using my python installation in MATLAB. I'm using version 2022b and this one is compatible with python 3.10. So I installed that version and it works fine with pycharm or when I run the .exe file and just use python. Then back in MATLAB i tried using both penv and pyverion using the file location for the python executable. This gave me somthing like this
pyversion
version: '3.10'
executable: 'C:\Users\omermb\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe'
library: 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\python310.dll'
home: 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0'
isloaded: 0
pyenv
ans =
PythonEnvironment with properties:
Version: "3.10"
Executable: "C:\Users\omermb\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe"
Library: "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\python310.dll"
Home: "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0"
Status: NotLoaded
ExecutionMode: OutOfProcess
It's in the WindowApps folder since I downloaded it thought the store.
However all funciton I try to rung give me the error message
py.abs(2)
Unable to resolve the name 'py.abs'.
Even the ones that should be built in python functions don't work.
So it's finding the correct executable but it does not seem to be working for some reason.
This has worked before, but I wanted to update to R2022 and python 3.10, and python 3.9 also was not working.
Any ideas?

回答(1 个)

Omer Babiker
Omer Babiker 2022-12-15
Ok I've managed to partially resolve this by using the python.org version of python 3.10, so that it is now located in
C:\Program Files\Python310
and MATLAB uses the executable there to run the python code.
However, I have run into a new problem where the a piece of code where I need python to load some data in a pkl file is much slower on one machine than the other. The same exact code in and identical folder, with the same exact file with the same matlab and python versions takes one minute on one machine and several hours on the other.
Anyone have any Ideas on how I can troubleshoot this?

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by