缺少Crypto库的解决方案

缺少Crypto库的解决方案

Python版本 3.9
之前安装Crypto库的时候,使用下面命令安装时报了一大堆错误

PS E:\Python Project\ApiTest> pip3 install pycrypto
Collecting pycrypto
  Using cached pycrypto-2.6.1.tar.gz (446 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pycrypto
  Building wheel for pycrypto (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pycrypto (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
      winrand.c
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(31): error C2061: ????: ???搃ntmax_t\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(32): error C2061: ????: ???搑em\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(32): error C2059: ????:\x93;\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(33): error C2059: ????:搣\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(35): error C2061: ????: ???搃maxdiv_t\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(35): error C2059: ????:\x93;\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(45): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(46): error C2146: ????: ??\x93)\x94(????揰Number\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(46): error C2061: ????: ???揰Number\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(46): error C2059: ????:\x93;\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(47): error C2059: ????:\x93)\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(50): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(51): error C2146: ????: ??\x93)\x94(????揰Numerator\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(51): error C2061: ????: ???揰Numerator\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(51): error C2059: ????:\x93;\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(51): error C2059: ????:\x93,\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(53): error C2059: ????:\x93)\x94
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(55): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(61): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(74): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(81): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(87): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(94): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\inttypes.h(100): error C2143: ????: ??搟\x94(?揰_cdecl\x94???)
      error: command 'D:\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.36.32532\\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
Failed to build pycrypto
ERROR: Could not build wheels for pycrypto, which is required to install pyproject.toml-based projects

后来发现直接使用这个命令解决问题:

pip install crypto pycryptodome
PS E:\Python Project\ApiTest> pip install crypto pycryptodome
Collecting crypto
  Downloading crypto-1.4.1-py2.py3-none-any.whl (18 kB)
Collecting pycryptodome
  Downloading pycryptodome-3.18.0-cp35-abi3-win_amd64.whl (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 36.8 kB/s eta 0:00:00
Collecting Naked (from crypto)
  Downloading Naked-0.1.32-py2.py3-none-any.whl (587 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 587.7/587.7 kB 43.9 kB/s eta 0:00:00
Collecting shellescape (from crypto)
  Downloading shellescape-3.8.1-py2.py3-none-any.whl (3.1 kB)
Requirement already satisfied: requests in e:\.pyenv\pyenv-win\versions\3.9.13\lib\site-packages (from Naked->crypto) (2.28.2)
Requirement already satisfied: pyyaml in e:\.pyenv\pyenv-win\versions\3.9.13\lib\site-packages (from Naked->crypto) (6.0)
Requirement already satisfied: charset-normalizer<4,>=2 in e:\.pyenv\pyenv-win\versions\3.9.13\lib\site-packages (from requests->Naked->crypto) (3.0.1)
Requirement already satisfied: idna<4,>=2.5 in e:\.pyenv\pyenv-win\versions\3.9.13\lib\site-packages (from requests->Naked->crypto) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in e:\.pyenv\pyenv-win\versions\3.9.13\lib\site-packages (from requests->Naked->crypto) (1.26.14)
Requirement already satisfied: certifi>=2017.4.17 in e:\.pyenv\pyenv-win\versions\3.9.13\lib\site-packages (from requests->Naked->crypto) (2022.12.7)
Installing collected packages: shellescape, pycryptodome, Naked, crypto
Successfully installed Naked-0.1.32 crypto-1.4.1 pycryptodome-3.18.0 shellescape-3.8.1

代码也正常
缺少Crypto库的解决方案_第1张图片

你可能感兴趣的:(python)