Windows下scons的问题
我尝试用scons为一个Python脚本构建一个可执行文件,但遇到了以下错误信息:
C:\WORKAREA\study>C:\Python26\Scripts\scons
scons: Reading SConscript files ...
scons: warning: No installed VCs
File "C:\WORKAREA\study\SConstruct", line 1, in <module>
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\WORKAREA\study\SConstruct", line 1, in <module>
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /OUT:fibo.exe fibo.py
'link' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [fibo.exe] Error 1
scons: building terminated because of errors.
看起来问题出在 link /nologo /OUT 这一部分,大家能帮我解决这个问题吗?
1 个回答
3
你是想把一个 .py 文件变成 .exe 文件,对吧?在这种情况下,你不需要 VC++ 编译器,而是需要一个像 py2exe 这样的工具。如果你想用 SCons 作为构建系统,你需要为 py2exe.exe 创建一个 SCons 构建器。大概可以这样做:
env = Environment()
def py2exe_action(target, source, env):
# execute py2exe <source> <output> here
return 0
env['BUILDERS']['Py2Exe'] = env.Builder(action = py2exe_action)
env.Default(env.Py2Exe(target = 'out_exe_file.exe', source = 'in_python_file.py'))