Windows 10 下安装pycrypto时出错的解决问题

错误信息如下:

Collecting pycrypto
  Using cached pycrypto-2.6.1.tar.gz (446 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pycrypto
  Building wheel for pycrypto (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [183 lines of output]
      running bdist_wheel

..........

winrand.c
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(31): error C2061: 语法错误: 标识符“intmax_t”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(32): error C2061: 语法错误: 标识符“rem”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(32): error C2059: 语法错误:“;”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(33): error C2059: 语法错误:“}”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(35): error C2061: 语法错误: 标识符“imaxdiv_t”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(35): error C2059: 语法错误:“;”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(45): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(46): error C2146: 语法错误: 缺少“)”(在标识符“_Number” 的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(46): error C2061: 语法错误: 标识符“_Number”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(46): error C2059: 语法错误:“;”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(47): error C2059: 语法错误:“)”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(50): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(51): error C2146: 语法错误: 缺少“)”(在标识符“_Numerator”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(51): error C2061: 语法错误: 标识符“_Numerator”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(51): error C2059: 语法错误:“;”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(51): error C2059: 语法错误:“,”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(53): error C2059: 语法错误:“)”
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(55): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(61): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(68): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(74): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(81): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(87): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(94): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      D:\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(100): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
      error: command 'D:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycrypto
  Running setup.py clean for pycrypto
Failed to build pycrypto
Installing collected packages: pycrypto
  Running setup.py install for pycrypto ... error
  error: subprocess-exited-with-error

解决方法:

将Microsoft Visual Studio安装目录(D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include)下的stdint.h文件复制到

D:\Windows Kits\10\Include\10.0.19041.0\ucrt

并将D:\Windows Kits\10\Include\10.0.19041.0\ucrt目录下的inttypes.h下的尖括号改成双引号(引号是引用非标准库的头文件,编译器从用户的工作目录开始搜索)

 然后重新安装:pip install pycrypto

  • 14
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值