【问题标题】:Execute python executable and script inlucing full path执行包含完整路径的python可执行文件和脚本
【发布时间】:2020-09-15 08:03:59
【问题描述】:

我正在尝试创建一个执行一系列 python 和 sql 脚本的 python 脚本。

有些需要使用一个 python 可执行文件执行,有些需要使用另一个。

我试过了

from subprocess import call 
call([r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\pythonw.exe", r"C:\Path\to\python\file\blabla.py"])

call([r"cd C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3", "pythonw.exe", r"C:\Path\to\python\file\blabla.py"])

但是脚本没有被执行。

我认为问题可能是“如何在 Windows 终端中执行包含完整路径的 .exe 文件”?

【问题讨论】:

    标签: python-3.x windows


    【解决方案1】:

    请检查我的代码。它在我身边运行良好。

    from subprocess import call
    
    call([r"C:\Python38\python.exe", r"E:\python\hello.py"])
    

    我认为,问题在于您使用的是 pythonw.exe。 如果你使用 pythonw.exe,你可以看到任何登录终端。 Pythonw 对于使用 GUI 运行脚本很有用。

    【讨论】:

      猜你喜欢
      • 2019-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      相关资源
      最近更新 更多