天使漫步IT工作室天使漫步IT工作室

pip install pyspider为mac安装pyspider失败解决方式

使用命令:

pip install pyspider

mac安装pyspider过程中,会出现错误,其中的一段异常信息如下:

  running install_lib
    copying build/lib.macosx-10.13-intel-2.7/pycurl.so -> /Library/Python/2.7/site-packages
    error: could not delete '/Library/Python/2.7/site-packages/pycurl.so': Permission denied

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/15/y_vy8r992z7d1w12s5n3sbh00000gn/T/pip-build-8BgDRW/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/15/y_vy8r992z7d1w12s5n3sbh00000gn/T/pip-28iZhQ-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/15/y_vy8r992z7d1w12s5n3sbh00000gn/T/pip-build-8BgDRW/pycurl/

从log中可以看出来,在安装pyspider的依赖包pycurl的时候出现了问题。从error: could not delete '/Library/Python/2.7/site-packages/pycurl.so': Permission denied这句话中我们很多人会以为由于权限不够,所以试图使用命令:

sudo pip install pyspider

然而你会发现sudo并没有任何作用,而且还给了一个警告,说pip已经不支持使用sudo这个操作来升级权限。经过网上查询(当然使用的是百度)说,mac在某某版本以后为了安全考虑,已经不让sudo来创建和拷贝一些目录。也就是上面会发生:

copying build/lib.macosx-10.13-intel-2.7/pycurl.so -> /Library/Python/2.7/site-packages

这句话拷贝失败的原因。也有网友支持,安装了build-tools工具后问题将会得到解决,然并卵。。。。

经过大google的帮助,博主终于找到一个办法,在命令中加入 --user 指定权属就可以。

pip install --user pyspider

即可,然后会出现以下Successfully installed的信息,表明安装成功啦!!!!:

landsnail:baishide_sales landsnail$ pip install --user  pyspider
Collecting pyspider
  Using cached pyspider-0.3.9.tar.gz
Requirement already satisfied: Flask>=0.10 in /Library/Python/2.7/site-packages (from pyspider)
Requirement already satisfied: Jinja2>=2.7 in /Library/Python/2.7/site-packages (from pyspider)
Requirement already satisfied: chardet>=2.2 in /Library/Python/2.7/site-packages (from pyspider)
Requirement already satisfied: cssselect>=0.9 in /Library/Python/2.7/site-packages (from pyspider)
Requirement already satisfied: lxml in /Library/Python/2.7/site-packages (from pyspider)
Collecting pycurl (from pyspider)
  Using cached pycurl-7.43.0.1.tar.gz
Requirement already satisfied: pyquery in /Library/Python/2.7/site-packages (from pyspider)
Requirement already satisfied: requests>=2.2 in /Library/Python/2.7/site-packages (from pyspider)
Requirement already satisfied: tornado>=3.2 in /Library/Python/2.7/site-packages (from pyspider)
Collecting Flask-Login>=0.2.11 (from pyspider)
  Using cached Flask-Login-0.4.1.tar.gz
Collecting u-msgpack-python>=1.6 (from pyspider)
  Using cached u_msgpack_python-2.4.1-py2.py3-none-any.whl
Requirement already satisfied: click>=3.3 in /Library/Python/2.7/site-packages (from pyspider)
Requirement already satisfied: six>=1.5.0 in /Library/Python/2.7/site-packages (from pyspider)
Collecting tblib>=1.3.0 (from pyspider)
  Using cached tblib-1.3.2-py2.py3-none-any.whl
Collecting wsgidav (from pyspider)
  Using cached WsgiDAV-2.2.4-py2.py3-none-any.whl
Requirement already satisfied: Werkzeug>=0.7 in /Library/Python/2.7/site-packages (from Flask>=0.10->pyspider)
Requirement already satisfied: itsdangerous>=0.21 in /Library/Python/2.7/site-packages (from Flask>=0.10->pyspider)
Requirement already satisfied: MarkupSafe>=0.23 in /Library/Python/2.7/site-packages (from Jinja2>=2.7->pyspider)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Python/2.7/site-packages (from requests>=2.2->pyspider)
Requirement already satisfied: idna<2.7,>=2.5 in /Library/Python/2.7/site-packages (from requests>=2.2->pyspider)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Library/Python/2.7/site-packages (from requests>=2.2->pyspider)
Requirement already satisfied: singledispatch in /Library/Python/2.7/site-packages (from tornado>=3.2->pyspider)
Requirement already satisfied: backports_abc>=0.4 in /Library/Python/2.7/site-packages (from tornado>=3.2->pyspider)
Collecting defusedxml (from wsgidav->pyspider)
  Using cached defusedxml-0.5.0-py2.py3-none-any.whl
Installing collected packages: pycurl, Flask-Login, u-msgpack-python, tblib, defusedxml, wsgidav, pyspider
  Running setup.py install for pycurl ... done
  Running setup.py install for Flask-Login ... done
  Running setup.py install for pyspider ... done
Successfully installed Flask-Login-0.4.1 defusedxml-0.5.0 pycurl-7.43.0.1 pyspider-0.3.9 tblib-1.3.2 u-msgpack-python-2.4.1 wsgidav-2.2.4

参考链接:how-to-use-pip-after-the-os-x-el-capitan-upgrade

本站原创,欢迎转载,转载敬请标明出处:天使漫步IT工作室 » pip install pyspider为mac安装pyspider失败解决方式
添加新评论