在OSX上使用pip安装Scrapy时出现错误和警告

时间:2014-02-01 22:47:18

标签: python macos terminal scrapy pip

我想在我的macbook OSX 10.9上安装Scrapy

我遵循了此处列出的所有先决条件:http://doc.scrapy.org/en/latest/intro/install.html

然后在终端中键入以下内容:pip install Scrapy

在终端的最底部,它说:

2 warnings and 6 errors generated.

error: command '/usr/bin/clang' failed with exit status 1

然后低于它说:

----------------------------------------
Cleaning up...
Command /Library/Frameworks/Python.framework/Versions/3.3/bin/python3 -c "import setuptools, tokenize;__file__='/private/var/folders/sj/fs5lzbyd7p37_jdkqw03_q4c0000gn/T/pip_build_johnmosely/Twisted/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/sj/fs5lzbyd7p37_jdkqw03_q4c0000gn/T/pip-lkdl1g-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/sj/fs5lzbyd7p37_jdkqw03_q4c0000gn/T/pip_build_johnmosely/Twisted
Storing debug log for failure in /Users/johnmosely/.pip/pip.log

我去看了,现在我的macbook上有一个名为“Scrapy”的文件夹,它包含一个名为“scrapy-scrapy-0.22.0-7-gcde9a8c.zip”的zip文件,但就是这样,我假设它没有成功安装?

或者我应该忽略错误和警告并解压缩zip文件?

感谢您的帮助。

编辑:我知道它没有安装,因为当我尝试启动一个新的scrapy项目时,终端会给我这个输出:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.3/bin/scrapy", line 3, in <module>
    from scrapy.cmdline import execute
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/scrapy/__init__.py", line 43, in <module>
    from twisted import version as _txv
ImportError: No module named 'twisted'

编辑2 - 以下是打印的6个错误:

^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
twisted/python/sendmsg.c:129:9: error: non-void function 'initsendmsg' should return a value [-Wreturn-type]
        return;
        ^
twisted/python/sendmsg.c:138:9: error: non-void function 'initsendmsg' should return a value [-Wreturn-type]
        return;
        ^
twisted/python/sendmsg.c:145:9: error: non-void function 'initsendmsg' should return a value [-Wreturn-type]
        return;
        ^
twisted/python/sendmsg.c:159:9: error: non-void function 'initsendmsg' should return a value [-Wreturn-type]
        return;
        ^
twisted/python/sendmsg.c:165:9: error: non-void function 'initsendmsg' should return a value [-Wreturn-type]
        return;
        ^
twisted/python/sendmsg.c:170:9: error: non-void function 'initsendmsg' should return a value [-Wreturn-type]
        return;

3 个答案:

答案 0 :(得分:2)

Scrapy需要扭曲才能工作,它正在尝试编译它但却遇到错误。我找到了bug tracker for this here。据我所知,这个bug仍然是开放的,所以在Python 3.3上,现在无法安装扭曲。您可能想尝试使用Python 2.7进行安装。

答案 1 :(得分:2)

不幸的是,Scrapy还不支持Python 3 - 由于扭曲的问题,端口没有启动。 Scrapy 0.22仅适用于Python 2.7。

答案 2 :(得分:0)

要成功安装Scrapy,您需要确保已经安装了Twisted工具。

当我尝试在Mac中安装Scrapy和Twisted时,遇到了同样的问题,“错误:命令'/ usr / bin / clang'失败,退出状态为1”。

在安装Xcode之后,此问题已解决。我不确定您是否使用像我这样的MacOS系统。如果是,这可能对您有帮助。

命令行:

xcode-select --install