緊接著 [Python] Windows 下安裝 pycrypto 時出現錯誤 又遇到個問題是在安裝 pyopenssl 的時候噴了下面的錯誤
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\git\App\venv\include -IC:\Users\lex_xu\AppData\Local\Programs\Python\Python38-32\include -IC:\Users\lex_xu\AppData\Local\Programs\Python\Python38-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcbuild\temp.win32-3.8\Release\_openssl.c /Fobuild\temp.win32-3.8\Release\build\temp.win32-3.8\Release\_openssl.obj _openssl.c build\temp.win32-3.8\Release\_openssl.c(546): fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2 ---------------------------------------- Running setup.py clean for cryptography Failed to build cryptography Failed building wheel for cryptography Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
解決方案:
- 安裝 Win32OpenSSL 32-bit 版
- 將
C:\Program Files (x86)\OpenSSL-Win32\include\openssl\
複製到目標環境C:\git\App\venv\Include\openssl\
- 將
C:\Program Files (x86)\OpenSSL-Win32\lib\
複製到C:\git\App\venv\libs
- 重新安裝 pyopenssl
參考: