【问题标题】:How to make a call to an executable from another executable/Python script on Mac?如何从 Mac 上的另一个可执行文件/Python 脚本调用可执行文件?
【发布时间】:2020-09-27 12:15:11
【问题描述】:

我用os.system("filename.exe")在windows上做同样的事情

但在 mac 上,pyinstaller 正在创建 unix 可执行文件并且没有扩展名。

我试过os.system("filename"),但没用。

我也尝试过os.system("./filename"),它适用于 python 脚本,但是当我制作可执行文件时它不起作用。

【问题讨论】:

  • 你试过os.system("bash filename")吗?
  • 我刚刚尝试了一个脚本。它os.system("./filename") 对我有用。您如何转换为可执行文件。
  • @Grayrigel 使用 pyinstaller 将其转换为 unix 可执行文件。
  • 我已经解决了这个问题,方法是使用 pyinstaller 上的 add-data 在这个可执行文件上添加该可执行文件

标签: python macos pyinstaller


【解决方案1】:

如果可执行文件是 python,只需导入文件,它将运行主块 假设这是a.py

print('hello')

在你的 python 代码中做

import a

输出将是

hello

【讨论】:

    猜你喜欢
    • 2011-01-29
    • 2014-07-03
    • 2018-11-04
    • 1970-01-01
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    • 2012-10-07
    • 1970-01-01
    相关资源
    最近更新 更多