Calling a python command from a deployed python library

1 回表示 (過去 30 日間)
Lawrence
Lawrence 2020 年 2 月 23 日
編集済み: Lawrence 2020 年 2 月 23 日
I'm having trouble calling Python functions in a function that I've deployed to a Python library.
My MATLAB function is:
function out = test_python()
out = py.sys.path;
end
This works in MATLAB, but if I deploy and call my function from the interpreter, I get the following:
>>> import test_python
>>> runtime = test_python.initialize()
>>> runtime.test_python()
[stack trace]
MatlabRuntimeError: An error occurred when evaluating the result from a function. Details:
File 'C:\...\test_python.m, line 2, in test_python'
Undefined variable "py" or class "py.sys.path".
I know Python can be found, since
function [version, executable, isloaded] = test_python()
[version, executable, isloaded] = pyversion;
end
returns
>>> import test_python
>>> runtime = test_python.initialize()
>>> runtime.test_python(nargout=3)
('3.7', 'D:\\Users\\...\\Anaconda3\\python.EXE', False)

回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by