2024-09-26 17:40:05 发布
网友
我想知道是否有一种方法可以从python代码中检查系统上是否存在matlab。到目前为止,我唯一能想到的就是:exists = os.system("matlab"),然后为command not found解析exists。但我几乎肯定这会:
exists = os.system("matlab")
command not found
那么有没有什么方法可以让我检查一下python系统上是否有matlab安装?在
谨致问候, 博格丹
假设您的系统调用正常,您可以检查matlab.exe像这样:
import os def matlab_installed(): for path in os.environ["PATH"].split(";"): if os.path.isfile(os.path.join(path, "matlab.exe")): return True return False
对于Unix,必须将split(“;”)更改为split(“:”)和“matlab.exe在Unix下调用的matlab可执行文件。在
假设您的系统调用正常,您可以检查matlab.exe像这样:
对于Unix,必须将split(“;”)更改为split(“:”)和“matlab.exe在Unix下调用的matlab可执行文件。在
相关问题 更多 >
编程相关推荐