can't run a python function from matlab
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kfir Weissman
le 23 Déc 2021
Commenté : Kfir Weissman
le 20 Déc 2024 à 7:02
hi, i try to run my order_files.py file.
i already add my venv from anaconda to matlab and when i run "pyenv" in matlab its
found it.
the problem is when i run the function "hel" in the order_files.py file from matlab i get this error:
"Unable to resolve the name py.order_files.hel."
what can i do about that?
2 commentaires
Anushka Perera
le 23 Déc 2021
Did you add the current folder to the Python search path? Something like this:
if count(py.sys.path,'') == 0
insert(py.sys.path,int32(0),'');
end
Réponse acceptée
Meet
le 20 Déc 2024 à 6:23
Hi Kfir,
You could try these steps to troubleshoot the issue:
- Ensure that the Python environment set in MATLAB "pyenv" is correctly pointing to your Anaconda environment. You can check this by running.
>> pyenv
2. Ensure that the directory containing file "order_files.py" is in the Python path.
if count(py.sys.path, 'directory_containing_pyFile') == 0
insert(py.sys.path, int32(0), 'directory_containing_pyFile');
end
3. Try restarting MATLAB and execute the command "py.order_files.hel()" again.
I hope this resolves the issue!!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!