Open a file from a specific program from python

荒凉一梦 提交于 2019-12-04 13:45:15

This cannot work since the system command gets executed in a subshell, and the chdir is only valid for that subshell. Replace the command by

os.system("open -a path/blender.app Import_mhx.blend")

or (much better)

subprocess.check_call(["open", "-a", os.path.join(path, "blender.app"),
                       "Import_mhx.blend"])

Have you tried telling the open command to open it WITH a specific application?

open -a /path/to/blender.app /path/to/Import_mhx.blend

Your first attempt was on the right track but you were really telling open to just open two different things. Not one with the other.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!