Visual C 中的 Python 脚本 2005 构建步骤未生成其他进程
我在调用 Python 2.5.1 脚本的 VC++ 2005 项目中有以下构建后步骤:
postbuild.py
postbuild.py 执行:
import os
os.system('cd') # cd is just a test, could be anything
该进程永远不会启动,并且与我尝试的任何其他进程相同,即使使用 subprocess.call 或 Popen而不是 os.system。
有谁知道与 Python 2.5.1 或 Visual C++ 2005 SP1 中的构建事件中的此类问题相关的任何信息?
I have the following post-build step in a VC++ 2005 project that calls a Python 2.5.1 script:
postbuild.py
postbuild.py does:
import os
os.system('cd') # cd is just a test, could be anything
The process never starts, and it's the same with any other process I try, even using subprocess.call or Popen instead of os.system.
Does anyone know about anything related to problems like this in Python 2.5.1 or in build events in Visual C++ 2005 SP1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了。 由于某种原因,使用“postbuild.py”作为构建后步骤会阻止 python 脚本生成其他进程,其中“python.exe postbuild.py”没有问题,“pythonw.exe postbuild.py”也没有问题。 我不确定为什么会发生这种情况,因为从 cmd.exe 使用时所有三种方法都是有效的。
但我想知道是否有人对此有解释。
Solved. For some reason, using "postbuild.py" as postbuild step inhibits the python script from spawning other processes, where "python.exe postbuild.py" has no problems, and neither "pythonw.exe postbuild.py". I'm not sure why this happens, as all three methods are valid when used from cmd.exe.
But I would like to know if anyone has an explanation for this.
请注意,构建后事件只会在构建完成后立即运行。 如果项目已经构建(因此不需要再次构建),则构建后步骤将根本不会运行。
如果您正在编辑 python 脚本,然后尝试通过构建项目来运行它,那么它不会执行任何操作,除非您每次都编辑项目中的文件以强制进行构建。
Be aware that the post build event will only run immediately after a completed build. If the project had already been built (and so does not need building again), then the post build step will not run at all.
If you're editing the python script and then trying to get it to run by building the project, then it's not going to do anything unless you edit a file within the project each time, to force the build to occur.