pip是python中的一個包管理工具,可以對Python包的查找、下載、安裝、卸載的作用。
yum -y install epel-release yum -y install python-pip
由於默認的pip源是國外的,所以下載速度會比較慢,python pip配置國內源
清華大學:https://pypi.tuna.tsinghua.edu.cn/simple 阿里雲:http://mirrors.aliyun.com/pypi/simple/ 豆瓣:http://pypi.douban.com/simple/
方式一:臨時使用國內pypi鏡像安裝
pip install -i http://pypi.douban.com/simple/ numpy pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com #此參數“--trusted-host”表示信任,如果上一個提示不受信任,就使用這個
方式二:永久使用國內pypi鏡像安裝
1、創建pip.conf文件
mkdir ~/.pip cd ~/.pip vi ~/.pip/pip.conf [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] trusted-host = https://pypi.tuna.tsinghua.edu.cn # trusted-host 此參數是為了避免麻煩,否則使用的時候可能會提示不受信任
2、升級pip的版本
pip install --upgrade pip
3、查看已經安裝的pip包
pip freeze or pip list //或 pip list 更多命令可以執行pip --help
4、pip相關的報錯
報錯一:/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.5) or chardet (2.2.1) doesn't match a supported version!
解決方法:
pip uninstall urllib3 pip uninstall chardet pip install requests
報錯二:
Python: error in moviepy setup command: ‘extras_require’ must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.
解決方法:setuptools版本太舊
pip install --upgrade setuptools