Calling Python from Matlab / Can I use Python installed by Anaconda? / "NULL pointer returned from Python."
Mostra commenti meno recenti
Would love to use some Python code a colleague wrote. I already have Anaconda installed, so I really don't want to install another version of Python (and associated libraries).
Tried:
pe = ...
pyenv('Version',...
fullfile('e:\', 'anaconda3', 'python.exe'));
myPythonVersion = pe.Version
py.print("Hello, Python!")
Got:
>> pe = ...
pyenv('Version',...
fullfile('e:\', 'anaconda3', 'python.exe'));
myPythonVersion = pe.Version
py.print("Hello, Python!")
myPythonVersion =
"3.8"
NULL pointer returned from Python.
>> py
>> pe
pe =
PythonEnvironment with properties:
Version: "3.8"
Executable: "e:\anaconda3\python.exe"
Library: "e:\anaconda3\python38.dll"
Home: "e:\anaconda3"
Status: NotLoaded
ExecutionMode: OutOfProcess
>>
Matlab Version R2020a (happy to upgrade, just too lazy right now...)
Risposta accettata
Più risposte (1)
Al Danial
il 30 Set 2022
Try this start-up sequence: first open an Anaconda Prompt or Anaconda PowerShell terminal. Then within that terminal window, type the path to the matlab executable (or is it a launch .bat file on Windows?). Or just type 'matlab' if it is in your system-wide search path.
Then within matlab just do
>> pyenv
with no arguments to see if matlab figured everything out on its own.
2 Commenti
Simon Mwakitabu
il 10 Gen 2024
This worked fine for me too. When anaconda launches Matlab, it directs it to a pathfile which has pyhton libraries in anaconda.
Hiren
il 16 Feb 2024
this worked for me too, thank you.
Categorie
Scopri di più su Call Python from MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!