Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”:报错解决

安装python的pycrypto包报错:Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”找了很多文档才解决,做个记录

使用的python版本:3.7.2

这个报错主要是对Microsoft Visual C++ 14.0 有依赖,那么首先 下载 Visual Studio

一、安装  Visual Studio

我下载的是2017版本,地址:https://my.visualstudio.com/Downloads?q=Visual%20Studio%202017

Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”:报错解决_第1张图片

打开后选择: 

Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”:报错解决_第2张图片

等待下载完成后,配置环境变量:

新建:VCINSTALLDIR,值为(Visual Studio安装路径):C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC

然后win+R运行cmd,执行命令set CL=/FI”%VCINSTALLDIR%\INCLUDE\stdint.h” %CL%

到此,Visual Studio安装环境配置都已完成;

二、本地安装pycrypto包

pycrypto包下载地址:Index of /pub/dlitz/crypto/pycrypto/

我下载的是:2.6.1版本

解压后:win+R运行cmd,进入解压文件夹:cd /d D:\VC\dist\pycrypto-2.6.1

执行命令:python setup.py install

如果报错:

------------------------

C:\Users\shuhe\Downloads\pycrypto-2.6.1>python setup.py install
running install
running build
running build_py
running build_ext
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Random.OSRNG.winrandom' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -IC:\Program Files\Python39\include -IC:\Program Files\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt -IC:\Program Files (x86)\Windows Kits\8.1\include\\shared -IC:\Program Files (x86)\Windows Kits\8.1\include\\um -IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt /Tcsrc/winrand.c /Fobuild\temp.win-amd64-3.9\Release\src/winrand.obj
winrand.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(26): error C2061: 语法错误: 标识符“intmax_t”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2061: 语法错误: 标识符“rem”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2059: 语法错误:“;”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(28): error C2059: 语法错误:“}”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2061: 语法错误: 标识符“imaxdiv_t”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2059: 语法错误:“;”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(40): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2146: 语法错误: 缺少“)”(在标识符“_Number”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2061: 语法错误: 标识符“_Number ”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2059: 语法错误:“;”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(42): error C2059: 语法错误:“)”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(45): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2146: 语法错误: 缺少“)”(在标识符“_Numerator”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2061: 语法错误: 标识符“_Numerator”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: 语法错误:“;”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: 语法错误:“,”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(48): error C2059: 语法错误:“)”
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(50): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(56): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(63): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(69): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(76): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(82): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(89): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(95): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2

-----------------------------------------------------

可以重启下电脑(这个不是必须的,大家可以试下不重启行不行),win+R运行cmd,执行命令:

set CL=/FI"%VCINSTALLDIR%\\INCLUDE\\stdint.h

然后直接进入解压文件夹:cd /d D:\VC\dist\pycrypto-2.6.1

执行命令:python setup.py install

看到:running install_egg_info 代表安装成功

你可能感兴趣的:(python学习,Python接口自动化,visual,studio)