Pip error: Microsoft Visual C++ 14.0 is required

Pip error: Microsoft Visual C++ 14.0 is required

我只是运行下面的命令:

pip install -U steem

并且安装一直运行良好,直到安装失败 pycrypto。 之后我做了

pip install cryptography

command 因为我以为是丢失的包。 所以我的问题是,如何在没有 pycrypto-error(或另外的 pycrypto-package)的情况下安装 steem 以及如何卸载我不需要的 cryptography-Package。 (我正在使用 Windows 7 和 Python 3)

Requirement already up-to-date: python-dateutil in c:\users\***\appdata\lo
cal\programs\python\python36\lib\site-packages (from dateparser->maya->steem)
...
Installing collected packages: urllib3, idna, chardet, certifi, requests, pycryp
to, funcy, w3lib, voluptuous, diff-match-patch, scrypt, prettytable, appdirs, la
ngdetect, ruamel.yaml, humanize, tzlocal, regex, dateparser, pytzdata, pendulum,
maya, ecdsa, pylibscrypt, ujson, toolz, steem
Running setup.py install for pycrypto ... error
Complete output from command c:\users\***\appdata\local\programs\pytho
n\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\
***~1\AppData\Local\Temp\pip-build-k6flhu5k\pycrypto\setup.py';f=getattr(
tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();
exec(compile(code, __file__, 'exec'))" install --record C:\Users\***N~1\AppDat
a\Local\Temp\pip-igpkll6u-record\install-record.txt --single-version-externally-
managed --compile:
running install
running build
running build_py
...
building 'Crypto.Random.OSRNG.winrandom' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

----------------------------------------
Command "c:\users\***\appdata\local\programs\python\python36\python.exe -u
-c "import setuptools, tokenize;__file__='C:\Users\***N~1\AppData\Local\
Temp\pip-build-k6flhu5k\pycrypto\setup.py';f=getattr(tokenize, 'open', open)(
__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code,   __fil
e__, 'exec'))" install --record C:\Users\***N~1\AppData\Local\Temp\pip-igpkll6
u-record\install-record.txt --single-version-externally-managed --compile"   faile
d with error code 1 in C:\Users\***N~1\AppData\Local\Temp\pip-build-    k6flhu5k\p
ycrypto\

您需要安装 Microsoft Visual C++ 14.0 才能安装 pycrypto:

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

在评论中询问使用哪个 link。使用 link 到 Visual C++ 2015 Build Tools。这将安装 Visual C++ 14.0 而无需安装 Visual Studio.

在评论中,您询问了不需要安装编译器的安装方法 pycrypto。 link 中的二进制文件似乎适用于比您使用的更早版本的 Python。一个 link 是 DropBox 帐户中的二进制文件。

我不建议下载第三方提供的密码库的二进制版本。保证您获得的 pycrypto 版本与您的 Python 版本兼容并且未使用任何后门构建的唯一方法是从源代码构建它。

安装Visual C++后,只需重新运行原来的命令:

pip install -U steem

要了解各种安装选项的含义,运行此命令:

pip help install

-U 选项的帮助说

-U, --upgrade        Upgrade all specified packages to the newest available
                     version. The handling of dependencies depends on the
                     upgrade-strategy used.

如果您还没有安装 steem 库,您可以 运行 不带 -U 选项的命令。

即使我的系统中安装了 Visual C++ 2015 (14.0),但我在尝试安装 pymssql 时遇到此错误。

我通过从 here 下载 pymssql 的 .whl 文件解决了这个错误。

下载后,可以通过以下命令安装:

pip install python_package.whl

希望对您有所帮助

在Windows,我强烈建议安装最新的Visual Stuido Community,它是免费的,如果你只安装vc_redist,你可能会错过一些构建工具,所以你可以很容易地安装包pip 而不是 wheel,它节省了很多时间

如果您已经安装了 Visual Studio 构建工具,但仍然出现该错误,那么您可能需要 "Modify" 安装以包含 Visual C++ 构建工具。

为此:

  1. 打开 Visual Studio 安装程序(如果需要,您可以在“开始”菜单中搜索)。

  2. 找到 Visual Studio 构建工具并单击 "Modify":

  1. 勾选Visual C++构建工具,然后点击右下角的"Modify"进行安装:

C++ 工具安装完成后,运行 再次执行 pip 命令,它应该可以工作了。

我遇到了同样的问题。找到修复 here.

基本上只要安装this

shasum 输出:

3e0de8af516c15547602977db939d8c2e44fcc0b  visualcppbuildtools_full.exe

md5sum 输出:

MD5 (visualcppbuildtools_full.exe) = 8d4afd3b226babecaa4effb10d69eb2e

运行 又是你的pip安装命令。如果一切正常,那就太好了。或者您可能会像我一样遇到以下错误:

Finished generating code
    LINK : fatal error LNK1158: cannot run 'rc.exe'
    error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe' failed with exit status 1158

在此处找到上述问题的修复方法: Visual Studio can't build due to rc.exe

基本上就是这样

Add this to your PATH environment variables:

C:\Program Files (x86)\Windows Kits.1\bin\x86

Copy these files:

rc.exe
rcdll.dll

From

C:\Program Files (x86)\Windows Kits.1\bin\x86

To

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin

它就像一个魅力

Pycrypto 的漏洞分配为 CVE-2013-7459 number, and the repo hasn't accept PRs since June 23, 2014

Pycryptodome is a drop-in replacement for the PyCrypto library, which exposes almost the same API as the old PyCrypto, see Compatibility with PyCrypto.

如果您还没有安装 pycrypto,您可以使用 pip install pycryptodome 安装 pycryptodome,这样您就不会遇到 Microsoft Visual C++ 14.0 问题。

我在搜索 "Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools" 后发现了这个问题。我在尝试 运行 时在 Azure DevOps 中遇到了这个错误pip install 从具有 C++ 扩展的源代码分发构建我自己的 Python 包。最后我所要做的就是在调用 pip install:[=16 之前升级 setuptools =]

pip install --upgrade setuptools

所以建议here about updating setuptools when installing from source archives is right after all:). That advice is given here也是。

作为安装 Visual C++ 的替代方法,有一种方法是在 Conda 中安装附加包(此选项不需要管理员权限)。这对我有用:

conda install libpython m2w64-toolchain -c msys2

尝试这样做:

py -m pip install pipwin
py -m pipwin install PyAudio

已更新 link 此处下载 Microsoft Visual C++ 14.0

我没有 Visual Studio 下载器

杀手级解决方案:安装nodejs并勾选install chocolatey and other necessary tools...选项,它将安装设置开发环境所需的工具。

针对此错误我遵循的三个步骤:

  1. 已安装 C++ 构建工具
  2. pip install --upgrade setuptools
  3. 尝试使用 conda 安装,conda 可能有不需要构建工具的编译版本

None 这里其他人提出的解决方案对我有用。

所以就我而言 我不得不卸载所有旧版本 来自我的计算机的 Microsoft Visual C++ Redistributable

应该只留下最新的(在我的例子中是 2015-2022)!

卸载后我运行这个命令:

pip install <your_lib_name>

之后一切正常。