尝试使用setup.py

时间:2019-06-25 23:48:43

标签: python windows-7-x64 setup.py pycryptodome

我正在Windows 7 64位计算机上设置python的cryptodome。我正在使用setup.py模块来实现此目的。我使用setup.py而不是pip的原因是因为我正在安装该程序的计算机没有外部Internet访问,因此pip无法正常工作。

我已经使用Windows SDK安装了64位c ++编译器,并按照以下link中的说明在cmd行上运行了以下命令。

  • 列表项cd“ C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1”
  • 列出项cmd / V:ON / K Bin \ SetEnv.Cmd / x64 / release
  • 列表项集DISTUTILS_USE_SDK = 1

运行setup.py时,出现以下错误消息:

  File "setup.py", line 443, in <module>
    set_compiler_options(package_root, ext_modules)
  File "C:\Python33\cryptodome\pycryptodome-3.8.2\compiler_opt.py", line 304, in
 set_compiler_options
    clang = compiler_is_clang()
  File "C:\Python33\cryptodome\pycryptodome-3.8.2\compiler_opt.py", line 239, in
 compiler_is_clang
    return test_compilation(source, msg="clang")
  File "C:\Python33\cryptodome\pycryptodome-3.8.2\compiler_opt.py", line 82, in
test_compilation
    objects = compiler.compile([fname], extra_postargs=extra_cc_options)
  File "C:\Python33\lib\distutils\msvc9compiler.py", line 461, in compile
    self.initialize()
  File "C:\Python33\lib\distutils\msvc9compiler.py", line 372, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python33\lib\distutils\msvc9compiler.py", line 288, in query_vcvarsal
    raise ValueError(str(list(result.keys())))
ValueError: ['path']

以下是看起来与错误相关的代码:

    #looks to contain a set of possible environment variable names
    interesting = set(("include", "lib", "libpath", "path"))


    #populates result with keys and values from actual environment variables
    stdout = stdout.decode("mbcs")
            for line in stdout.split("\n"):
                line = Reg.convert_mbcs(line)
                if '=' not in line:
                    continue
                line = line.strip()
                key, value = line.split('=', 1)
                key = key.lower()
                if key in interesting:
                    if value.endswith(os.pathsep):
                        value = value[:-1]
                    result[key] = removeDuplicates(value)


    #tests whether all the keys within result are in interesting
    if len(result) != len(interesting):
         raise ValueError(str(list(result.keys())))

这可能是由于环境变量中缺少某些值吗?如果是这样,那这些价应该是什么?

1 个答案:

答案 0 :(得分:1)

尽管错误消息不是很有帮助,但我通过将3个值添加到机器上的环境变量中来解决了这个问题:lib,include,libpath(路径已添加)。