[英]How to run a Python script in a Conda environment from MATLAB?
我正在写一个 package 给别人,所以我试图使安装、依赖和使用尽可能简单。 The top-level calls for the package are in MATLAB but, at one point, I'd like to run a Python script from my MATLAB function. 我不知道用户是否会在 Unix 或 Windows 上。 到目前为止,我已经为我的 Python 脚本使用了 Conda 环境,因为它使用特定版本的 Scipy 和 Tensorflow。
是否有独立于平台的方法来激活 Conda 环境并从 MATLAB 调用 Python 脚本? Or even better, have a copy of Python (and it's dependencies) in a subdirectory of the MATLAB script so I could, for instance, give the entire package on a USB stick and not worry about different Python installations?
感谢您的任何见解。
没有一种独立于平台的方法可以让 MATLAB 使用conda
环境。 However, as I mentioned in this answer, you can explicitly tell MATLAB where to look for the Python interpreter and libraries of your environment, and can even de-bug without having to restart MATLAB every time you change the Python script you are trying to run .
在从 MATLAB 使用conda
环境之前,您不需要激活它,因此您的部分问题没有实际意义。 MATLAB 只是使用解释器,因此只要在conda
环境中安装了所有必需的库,您的 Python 代码将从 MATLAB 运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.