Mac OS安装Scrapy失败
Posted CityPe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac OS安装Scrapy失败相关的知识,希望对你有一定的参考价值。
报错:
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling six-1.4.1: Exception: Traceback (most recent call last):
原因分析:
:Scrapy依赖six库,但是系统的six库比较老,安装scrapy需要卸载之后安装一个新的。但是Mac OS本身也依赖six,导致无法删除,因此没有办法安装Scrapy。
解决的方式:使用virtualenv来安装。
sudo pip install virtualenv
virtualenv scrapyenv
cd scrapyenv
source bin/activate
pip install Scrapy
安装完成之后,安装如下包:
好了,可以使用scrapy startproject yourproject
开始你的爬虫之旅了。
转自:http://blog.csdn.net/tangch0516/article/details/51378664
执行卸载和重装six的时候 not premitted
于是:
xcode-select --install
sudo pip install scrapy --ignore-installed six
然后错误:
ImportError:cannot import name xmlrpc_client
原因还是因为没有six
终端下执行
sudo rm -rf /Library/Python/2.7/site-packages/six*
sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six*
sudo pip install six
卸载掉six并重装,再次查看Scrapy版本,搞定。
如果执行第二条语句出错的话 就说明即便是sudo权限还是被拦截了
这时候:
重启电脑 进入 recovery mode (点击command+R) 在左上角的终端中 输入:csrutil disable
成功!
Last login: Thu Jan 12 21:39:41 on console
ChendeMacBook-Pro:~ Chen$ sudo rm -rf /Library/Python/2.7/site-packages/six*
Password:
ChendeMacBook-Pro:~ Chen$ sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six*
ChendeMacBook-Pro:~ Chen$ sudo pip install six
The directory ‘/Users/apple/Library/Caches/pip/http‘ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo‘s -H flag.
The directory ‘/Users/apple/Library/Caches/pip‘ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo‘s -H flag.
Requirement already satisfied: six in ./Library/Python/2.7/lib/python/site-packages
ChendeMacBook-Pro:~ Chen$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrapy
>>>
以上是关于Mac OS安装Scrapy失败的主要内容,如果未能解决你的问题,请参考以下文章