Mac OS安装Scrapy失败

本文详细介绍了在MacOS环境下遇到的Scrapy安装问题及其解决步骤。由于系统自带的six库与Scrapy存在版本冲突,文章提供了使用virtualenv创建虚拟环境的方法,并给出了具体的命令行操作流程。

报错:

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来安装。

  1. sudo pip install virtualenv
  2. virtualenv scrapyenv
  3. cd scrapyenv
  4. source bin/activate
  5. pip install Scrapy  

 

安装完成之后,安装如下包:

scapy安装之后的包

好了,可以使用scrapy startproject yourproject开始你的爬虫之旅了。

转自:http://blog.youkuaiyun.com/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

>>> 

 

转载于:https://www.cnblogs.com/CityPe/p/6279765.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值