美文网首页爬虫
mac安装scrapy报错

mac安装scrapy报错

作者: 我拿buff谢谢 | 来源:发表于2017-08-22 20:13 被阅读81次

    mac自带的pyton版本为2.7,目前scrapy在2.7版本上运行最稳定

    一、安装步骤

    1.打开terminal,输入

    $ sudo ruby  -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    2.安装wget (若已安装好wget,这步跳过)

    $ sudo brew install wget

    3.安装command line tools

    $ sudo xcode-select --install

    4.安装pip

    $ wget https://bootstrap.pypa.io/get-pip.py

    $ python get-pip.py

    5.安装scrapy

    $ sudo pip install scrapy

    二、报错信息

    OSError: [Errno 1] Operation not permitted: '/tmp/pip-1_nHcH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

    $ sudo pip install Scrapy --upgrade --ignore-installed six  //表示忽略已安装的six库,因为mac的python自带就有这个库,然而这个库版本比较旧

    ImportError: cannot import name xmlrpc_client

    $ sudo easy_install -U six

    三、使用国内的pip源

    通常我们直接pip install 去安装库都会报出超时或者安装得很慢甚至中断。向大家分享使用国内pip源的方法

    国内源:

    新版ubuntu要求使用https源,要注意。

    清华:https://pypi.tuna.tsinghua.edu.cn/simple

    阿里云:http://mirrors.aliyun.com/pypi/simple/

    中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

    华中理工大学:http://pypi.hustunique.com/

    山东理工大学:http://pypi.sdutlinux.org/

    豆瓣:http://pypi.douban.com/simple/

    临时使用:

    可以在使用pip的时候加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple

    例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。

    永久修改,一劳永逸:

    Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

    内容如下:

    [global]

    index-url = https://pypi.tuna.tsinghua.edu.cn/simple

    [install]

    trusted-host=mirrors.aliyun.com

    windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容同上。

    相关文章

      网友评论

        本文标题:mac安装scrapy报错

        本文链接:https://www.haomeiwen.com/subject/nxxrdxtx.html