Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The MATLAB® Engine API for Python® provides a package to integrate MATLAB functionality directly with a Python application, creating an interface to call functions from your MATLAB installation from Python code.
MATLAB Engine API for Python can be installed directly from the Python Package Index.
$ python -m pip install matlabengine==24.2.1
Prior to installation, check the default install location of MATLAB by calling matlabroot
in a MATLAB Command Window. By default, Linux installs MATLAB at:
/usr/local/MATLAB/R2024b
When MATLAB is not installed in the default location, the bin/architecture directory within the MATLAB root directory must be added to the environment variable LD_LIBRARY_PATH. The path can be added to the environment variable within the shell startup configuration file (for example, .bashrc for bash shell or .tcshrc for tcsh).
# in .bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<matlabroot>/bin/glnxa64
# in .tcshrc
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:<matlabroot>/bin/glnxa64
MATLAB Engine API for Python can be installed directly from the Python Package Index.
$ python -m pip install matlabengine==24.2.1
Prior to installation, check the default install location of MATLAB by calling matlabroot
in a MATLAB Command Window. By default, macOS installs MATLAB at:
/Applications/MATLAB_R2024b.app
When MATLAB is not installed in the default location, the bin/architecture directory within the MATLAB root directory must be added to the environment variable DYLD_LIBRARY_PATH. The path can be added to the environment variable within the shell startup configuration file (for example, .bashrc for bash shell or .tcshrc for tcsh).
# in .bashrc
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:<matlabroot>/bin/maci64
# in .tcshrc
setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:<matlabroot>/bin/maci64
MATLAB Engine API for Python can be installed directly from the Python Package Index.
$ python -m pip install matlabengine==24.2.1
matlab.engine
package into the Python session.start_matlab
. The start_matlab
function returns a Python object which enables you to pass data and call functions executed by MATLAB.>>> import matlab.engine
>>> eng = matlab.engine.start_matlab()
>>> eng.sqrt(4.0)
2.0
exit
or quit
function to stop the engine. Exiting Python with an engine running stops the engine and its MATLAB processes.>>> eng.quit()
See Start and Stop MATLAB Engine for Python for advanced startup examples.
You can call any MATLAB function directly and return the results to Python.
>>> eng.plus(2, 3)
5
>>> eng.isprime(37)
True
>>> eng.gcd(100.0, 80.0, nargout=3)
(20.0, 1.0, -1.0)
See Call MATLAB Functions from Python for more usage examples.
Limitations of the MATLAB Engine API for Python can be found here.
See Troubleshoot MATLAB Errors in Python for troubleshooting assistance.
The license is available in the LICENSE.txt file within this repository.
Technical issues or enhancement requests can be submitted here.
Copyright © 2022 MathWorks, Inc. All rights reserved.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
Mac OS is a trademark of Apple Inc., registered in the U.S. and other countries.
"Python" and the Python logos are trademarks or registered trademarks of the Python Software Foundation, used by MathWorks with permission from the Foundation.
FAQs
A module to call MATLAB from Python
We found that matlabengine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.