V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
redhatping
V2EX  ›  Python

安装 pyspider 出错,错误日志已经贴上来,大家帮忙看看,谢谢。

  •  
  •   redhatping · 2015-05-04 00:49:20 +08:00 · 8846 次点击
    这是一个创建于 3286 天前的主题,其中的信息可能已经有所发展或是发生改变。
    环境:mac 10.10.3 python 2.7


    sudo pip install pyspider


    1 error generated.
    error: command 'cc' failed with exit status 1

    ----------------------------------------
    Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-rQTT_8/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PLFb70-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-rQTT_8/lxml


    谢谢了。
    22 条回复    2015-07-17 17:19:31 +08:00
    binux
        1
    binux  
       2015-05-04 00:57:31 +08:00
    STATIC_DEPS=true sudo pip install lxml
    redhatping
        2
    redhatping  
    OP
       2015-05-04 01:23:16 +08:00
    @binux error: command 'cc' failed with exit status 1

    ----------------------------------------
    Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-0syUSb/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-b0HQ2W-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-0syUSb/lxml

    安装了你说的,lxml,一样出错了,是不是更新了xcode的原因?
    binux
        3
    binux  
       2015-05-04 01:33:44 +08:00
    那就 xcode-select
    redhatping
        4
    redhatping  
    OP
       2015-05-04 02:06:10 +08:00
    @binux 可以说清楚些吗?? 到底怎么回事啊,pyspider在安装lxml出了问题,按照
    redhatping
        5
    redhatping  
    OP
       2015-05-04 02:08:35 +08:00
    export CFLAGS=-Qunused-arguments
    export CPPFLAGS=-Qunused-arguments

    没用 ;),谢谢了
    redhatping
        6
    redhatping  
    OP
       2015-05-04 02:11:07 +08:00
    env ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install lxml
    也没用, 我晕, 真是xcode原因,怎么办啊。
    redhatping
        7
    redhatping  
    OP
       2015-05-04 02:25:59 +08:00
    用easy_install发现:
    /private/tmp/pip-build-feNg8E/lxml/src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found

    头文件没发现,这装个lxml。。。头大
    redhatping
        8
    redhatping  
    OP
       2015-05-04 02:46:08 +08:00
    是不是没有安装 : libxml2 and libxslt的原因,但是pip install,没有啊
    ericls
        9
    ericls  
       2015-05-04 06:14:33 +08:00   ❤️ 1
    @redhatping

    brew install libxml2
    brew install libxslt
    brew link libxml2 --force
    brew link libxslt --force

    pip install lxml
    binux
        10
    binux  
       2015-05-04 08:33:07 +08:00 via Android   ❤️ 1
    @redhatping 你自己搜索一下不就知道了
    redhatping
        11
    redhatping  
    OP
       2015-05-04 09:17:40 +08:00
    楼上正确, 总算解决来, 原来是缺失这两个库。。 把我累的。
    aszxqw
        12
    aszxqw  
       2015-05-04 09:22:58 +08:00
    @redhatping 目测似乎你不知道你的楼上就是pyspider的作者吧。。。。
    redhatping
        13
    redhatping  
    OP
       2015-05-04 09:43:35 +08:00
    确实不知道, 😓, 通过这一次pyspider的安装, 五个小时的折腾 , 总算弄明白。

    pyspider--依赖python包---lxml ---- 依赖于系统包 ,libxm2,libxslt. ( 为什么不能一条龙呢?)

    至于系统包是什么? 不懂 ,刚迁移到mac中。

    brew 是什么都不懂。。。

    谢谢大家了。
    proudzhu
        14
    proudzhu  
       2015-05-04 09:53:23 +08:00 via Android   ❤️ 1
    因为库文件不是用 Python 写的啊
    binux
        15
    binux  
       2015-05-04 10:25:55 +08:00
    @redhatping 你用 osx lxml 为关键词搜就能搜到这些方法。
    官方的 `STATIC_DEPS=true sudo pip install lxml` 会自动下载依赖,静态链接。

    一般缺库会报缺头文件,你又没有报
    #include "libxml/xmlversion.h"

    那就 xcode-select 咯

    反正我不信你把 log 贴全了,我不信你每次出错都是一样的。
    monsabre1
        16
    monsabre1  
       2015-05-04 10:29:52 +08:00
    这程序代码比较垃圾
    试用了下 没法用 放弃了
    还是留别人浪费生命吧
    wibile
        17
    wibile  
       2015-05-04 11:13:23 +08:00
    scrapy吧,成熟稳定一些,也全面。精神上支持pyspider
    donghouhe
        18
    donghouhe  
       2015-05-04 11:31:05 +08:00 via Android
    我在mac安装lxml也失败,不过我选择的解决方法是改装虚拟机里,debian pip安装lxml很顺溜, 现在看来原来有这样的解决方法。
    redhatping
        19
    redhatping  
    OP
       2015-05-04 11:33:22 +08:00
    嗯,没有贴全, 我后面用easy_install 安装, 很明显报错了, 缺头文件。
    于是brew。。。。
    现在成功了。
    redhatping
        20
    redhatping  
    OP
       2015-05-04 11:35:08 +08:00
    @proudzhu 亲,因为是windows过来的, 完全搞不懂mac os 这一些的概念和命令, 网上搜索又比较杂,有没有这样的书籍购买, 彻底想补一下。 谢谢
    proudzhu
        21
    proudzhu  
       2015-05-04 12:18:33 +08:00
    @redhatping 没用过 MacOS ,我用 linux 的,用着用着就知道这些概念了。。。
    echoer
        22
    echoer  
       2015-07-17 17:19:31 +08:00
    很好的贴,我也遇到这个问题了。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2201 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 10:06 · PVG 18:06 · LAX 03:06 · JFK 06:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.