错误代码1安装Scrapy


问题内容

我正在尝试为Python安装Scrapy模块。我正在使用命令:

pip install Scrapy

但是我收到以下错误:

Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools, tokenize;__file__='/private/var/folders/b4/nrmj5jf105lcv1_kf1yk9gh40000gn/T/pip-build-aNQoXA/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/b4/nrmj5jf105lcv1_kf1yk9gh40000gn/T/pip-B_akAd-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/b4/nrmj5jf105lcv1_kf1yk9gh40000gn/T/pip-build-aNQoXA/lxml

我对此进行了一些研究,并在此处此处尝试了几种不同的解决方案,但均无济于事。


问题答案:

显然我需要安装Xcode命令行工具。(即使您已安装Xcode。)我具有最新版本的Xcode,但仍需要安装命令行工具。

xcode-select --install

然后运行pip install scrapy正常。