Windows下想通过python安装mitmproxy,发现一直报错“无法打开包括文件: “openssl/opensslv.h””,几经折腾,看错误日志,在Windows安装openssl也不行(Windows下安装openSSL,百度网盘下载链接:https://pan.baidu.com/s/1ieymsjh9g3IibiaawFfDzg
提取码:zxdg),
错误日志:
building '_openssl' extension
creating build\temp.win-amd64-3.8\Release\build
creating build\temp.win-amd64-3.8\Release\build\temp.win-amd64-3.8
creating build\temp.win-amd64-3.8\Release\build\temp.win-amd64-3.8\Release
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\python38\include -Ic:\python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcbuild\temp.win-amd64-3.8\Release\_openssl.c /Fobuild\temp.win-amd64-3.8\Release\build\temp.win-amd64-3.8\Release\_openssl.obj
_openssl.c
build\temp.win-amd64-3.8\Release\_openssl.c(546): fatal error C1083: 无法打开包括文件: “openssl/opensslv.h”: No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
最后通过以下解决办法解决:
1、将openssl安装目录下的:C:\Program Files\OpenSSL-Win64\lib 拷贝到 C:\Python38\libs
2、将openssl安装目录下的:C:\Program Files\OpenSSL-Win64\include 拷贝到 C:\Python38\include
再次执行:pip install mitmproxy
安装成功截图如下:
![](https://i-blog.csdnimg.cn/blog_migrate/24e98224ef4a19ca1ac5132e18b98ead.png)
image.png