美文网首页
安装PyCrypto时VS编译出错

安装PyCrypto时VS编译出错

作者: Aska偶阵雨 | 来源:发表于2020-10-22 16:04 被阅读0次

    前言

    最近做了个project,需要用到PyCrypto。

    PyCrypto在Windows下需要使用VC进行编译,不过Python模块在Windows平台编译坑点比较多。

    如:

    winrand.c

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(27): error C2061: 语法错误: 标识符“intmax_t”

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(28): error C2061: 语法错误: 标识符“rem”

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(28): error C2059: 语法错误:“;”

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(29): error C2059: 语法错误:“}”

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(31): error C2061: 语法错误: 标识符“imaxdiv_t”

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(31): error C2059: 语法错误:“;”

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(41): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)

    D:\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(42): error C2146: 语法错误: 缺少“)”(在标识符“_Number”的前面)

    ... blah blah blah ...

    解决方案

    查看原文。vs安装pycrypto-2.6.1报错处理_因上努力 ,果上随缘-CSDN博客

    处理方式:

    修改文件 setup.py

    def detect_modules (self):

        # Read the config.h file (usually generated by autoconf)

        if self.compiler.compiler_type == 'msvc' and False:

            # Add special include directory for MSVC (because MSVC is special)

            self.compiler.include_dirs.insert(0, "src/inc-msvc/")

            ac = self.__read_autoconf("src/config.h")

        else:

            ac = self.__read_autoconf("src/config.h")

    在if self.compiler.compiler_type == 'msvc'后加上and False,使special失效。

    然后拷贝\src\inc-msvc\config.h 到\src\config.h 编译即可。

    #python

    相关文章

      网友评论

          本文标题:安装PyCrypto时VS编译出错

          本文链接:https://www.haomeiwen.com/subject/isqpmktx.html