【问题标题】:Error while installing Scrapy error: Microsoft Visual C++ 14.0 is required安装 Scrapy 时出错错误:需要 Microsoft Visual C++ 14.0
【发布时间】:2020-10-03 17:50:55
【问题描述】:

我发现scrapy 是一个很棒的抓取工具,所以我尝试在我的机器上安装scrapy,但是当我尝试执行pip install scrapy 时,它安装了一段时间并抛出了这个错误..

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

我尝试在虚拟环境中安装它,但问题仍然存在。

编辑: 这是我在出错后得到的结果..

    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 "d:\pycharmprojects\environments\scrapyenv\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\User\\AppData\\Local\\Temp\\pip-build-arbeqlly\\Twisted\\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\User\AppData\Local\Temp\pip-jdj93131-record\install-record.txt --single-version-externally-managed --compile --install-headers d:\pycharmprojects\environments\scrapyenv\include\site\python3.5\Twisted" failed with error code 1 in C:\Users\User\AppData\Local\Temp\pip-build-arbeqlly\Twisted\

有什么帮助吗?

【问题讨论】:

  • 您是否尝试访问建议的网址?
  • 是的,我做到了,但问题是 scrapy 与 Visual Studio 有什么关系
  • 我会假设 scrapy 正在使用底层 C/C++ 库来提高速度。我原以为如果你通过轮子安装,Windows 会被预先打包,但我可能弄错了。 (另请注意,stackoverflow.com/questions/32350375/… 对 Mac 用户也有类似问题)
  • 目前在Windows上安装Scrapy的推荐方式是use Anaconda/Miniconda with the conda-forge channel

标签: python scrapy


【解决方案1】:

使用 Conda 安装

如果你有 conda 使用:conda install -c anaconda scrapy

或者

使用 pip 安装

在此位置下载https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted

//Download the whl file of same version as Python version here cp27 means python2.7
pip install Twisted-18.9.0-cp27-cp27m-win_amd64.whl 
pip install scrapy

【讨论】:

  • 下载 Twisted 文件并使用 pip 安装它对我来说绝对是最快和最简单的解决方案
  • 神圣的通心粉这就是诀窍。无需下载 4 GB 的 Visual Studio。
【解决方案2】:

更新 正如有人在编辑中指出的那样,如果您只下载 vc_redist.x64.exe 它只有 15MB,为此请转到“其他工具和框架”并选择 MS Visual C++

通过安装here的工具解决了这个问题

问题是一些 python 模块需要 C++ 工具来编译,因为它们是用 C++ 编写的。

下载设置后,您可以选择特定工具或下载提供的其他工具。

它大约是 4 GB,但如果将来您需要使用其他一些用 C++ 制作的模块,它就可以解决这个问题。

【讨论】:

    【解决方案3】:

    但问题是scrapy与visual studio有什么关系

    一些 python 模块需要 C/C++ 编译器来构建。这就是您需要 Visual Studio 的原因。

    引用Scrapy Installation Guide:

    Scrapy 依赖的一些二进制包(如 Twisted、lxml 和 pyOpenSSL) 需要一个可以安装的编译器,如果你安装它会失败 没有安装 Visual Studio。

    【讨论】:

    • 但是当我这样做时 lxml 这不是问题
    【解决方案4】:

    我刚刚安装了C++的Visual Studio桌面工具并解决了。

    【讨论】:

      【解决方案5】:

      安装和使用 anaconda(一个 Python 包管理器)而不是 pip。

      here 下载 anaconda 然后使用:

      conda install scrapy
      

      【讨论】:

        【解决方案6】:

        您必须安装 Python 2.7 然后您必须将 Python27 和 Pyhton27/Scripts 放在路径上并安装 Visual C++ 14 或更高版本并在您的 cmd 中输入 pip install Scrapy

        【讨论】:

          【解决方案7】:

          只安装“vc_redist.x64.exe”对我不起作用。 我下载了 Visual Studio 2019 Community here,然后选择了“C++ 桌面开发”,然后只选择了前两个框(见右下图):

          这对我有用。

          【讨论】:

            【解决方案8】:

            刚刚安装了 Visual Studio 构建工具,问题就解决了。编码愉快!

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2020-06-10
              • 2018-04-25
              • 2020-08-08
              • 2016-12-21
              • 2021-05-03
              相关资源
              最近更新 更多