1.安装pip
pip是python包管理工具,Mac系统自带Python,里面有easy_install
sudo easy_install pip
pip区分python2、python3,用其安装的第三方报分别用不同的版本运行,包在不同版本的系统库中
2.pip警告
(1)使用命令:sudo pip install numpy时,可能遇到:
The directory '/Users/huangqizhi/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.
说得很清楚,是pip目录的属主不是sudo的root用户。如果必须用sudo pip,更改pip目录属主即可:
sudo chown root /Users/huangqizhi/Library/Caches/pip
(2)pip安装时,可能遇到:
/Library/Python/2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
解决方法:安装requests,注意后面带[security]:
pip install requests[security]
3.用pip安装第三方库时权限问题
安装pygame时报如下错误:
OSError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pygame'
由于El Capitan引入了SIP机制(System Integrity Protection),默认下系统启用SIP系统完整性保护机制,无论是对于硬盘还是运行时的进程限制对系统目录的写操作。 这也是我们安装ipython失败的原因….
现在的解决办法是取消SIP机制,具体做法是:
重启电脑,按住Command+R(直到出现苹果标志)进入Recovery Mode(恢复模式)
左上角菜单里找到实用工具 -> 终端
输入csrutil disable回车
重启Mac即可
如果想重新启动SIP机制重复上述步骤改用csrutil enable即可
yyzanlldeMacBook-Pro:~ yyzanll$ csrutil status
System Integrity Protection status: disabled.
另一种方式为:
不一定成功
sudo pip install pygame --upgrade --ignore-installed
或者:
$ pip install --upgrade pip
$ sudo pip install numpy --upgrade --ignore-installed
$ sudo pip install scipy --upgrade --ignore-installed
$ sudo pip install scikit-learn --upgrade --ignore-installed
4.安装scrapy
安装scrapy遇到的坑
5.安装requests
pip install requests
6.安装BeautifulSoup4
pip install BeautifulSoup4
7.使用Chrome浏览器
8.安装jupyter
pip install jupyter
jupyter notebook
9.安装firebug