py_addpath(director​y, MATLAB_too)

버전 1.2.0.0 (2.01 KB) 작성자: Eric Fields
Modify Python search path from MATLAB
다운로드 수: 495
업데이트 날짜: 2017/11/9

라이선스 보기

편집자 메모: This file was selected as MATLAB Central Pick of the Week

py_addpath works like the MATLAB function addpath, but updates the PYTHONPATH instead of the MATLAB path.
Starting in MATLAB 2014b, Python code can be called directly from MATLAB (assuming you have a Python interpreter and it is known to MATLAB). For example, py.statistics.mean([1, 2, 3]) would call the mean function from the statistics module in the Python standard library and return the mean of the array.

To use a function in a Python module from MATLAB, that module must be on the Python search path. Adding its location to the MATLAB search path won't work.

Modules in the standard library or properly installed third party packages are already on the Python search path. But if you have written your own Python functions, you may want to add their location to the search path in the same way you add the location of MATLAB functions and scripts to the MATLAB search path.

py_addpath adds a directory to the Python search path in the same way that the MATLAB function addpath adds a directory to the MATLAB search path. Like addpath, py_addpath only adds the directory for the currently active session: it does not permanently change the PYTHONPATH.

The optional output of py_addpath is the updated list of directories on the Python search path as a cell array.

인용 양식

Eric Fields (2024). py_addpath(directory, MATLAB_too) (https://www.mathworks.com/matlabcentral/fileexchange/62703-py_addpath-directory-matlab_too), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2014b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
도움

줌: zipToolsPy

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.0

Fixed description formatting
Now adds the full path even when the input is a relative path.

1.1.0.0

Added informative error messages.

1.0.0.0

Fixed typos in description.