- 最近项目中用到Python来爬虫,在安装pip的时候出了点小问题,特此记录下来:
pip是常用的Python包管理工具,类似于Java的maven。用python的同学,都离不开pip。 在新mac中想用home-brew安装pip时,遇到了一些小问题:
jianming:~ kang$ brew install pip
Error: No available formula with the name "pip"
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.org/en/stable/installing/
由此可见,在home-brew中,pip的安装是跟python一起的。
jianming:~ kang$ sudo easy_install pip
Password:
Searching for pip
Reading https://pypi.python.org/simple/pip/
...
安装成功!
- 在安装pyspider时出现以下问题:
Found existing installation: six 1.4.1
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):
File “/Library/Python/2.7/site-packages/pip/basecommand.py”, line 209, in main
status = self.run(options, args)
File “/Library/Python/2.7/site-packages/pip/commands/install.py”, line 317, in run
prefix=options.prefix_path,
File “/Library/Python/2.7/site-packages/pip/req/req_set.py”, line 726, in install
requirement.uninstall(auto_confirm=True)
File “/Library/Python/2.7/site-packages/pip/req/req_install.py”, line 746, in uninstall
paths_to_remove.remove(auto_confirm)
File “/Library/Python/2.7/site-packages/pip/req/req_uninstall.py”, line 115, in remove
renames(path, new_path)
File “/Library/Python/2.7/site-packages/pip/utils/init.py”, line 267, in renames
shutil.move(old, new)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 302, in move
copy2(src, real_dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 131, in copy2
copystat(src, dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: ‘/tmp/pip-KGtuUf-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info’
最终的解决方法在这篇博客中:http://xiaorui.cc/2016/03/27/%E8%A7%A3%E5%86%B3mac-osx%E4%B8%8Bpip%E5%AE%89%E8%A3%85ipython%E6%9D%83%E9%99%90%E7%9A%84%E9%97%AE%E9%A2%98/