python在线和离线安装包
建议先安装虚拟环境方便对包进行管理:安装virtualenv和virtualenvwrapper
也可安装anaconda快速搭建环境
在线安装:
pip install **
通过镜像源安装
豆瓣:http://pypi.douban.com/simple/
阿里云:http://mirrors.aliyun.com/pypi/simple/
清华:https://pypi.tuna.tsinghua.edu.cn/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
安装示例:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple virtualenvwrapper==33.1.1
# 信任该镜像源
pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com **
离线安装
主要分为后缀是".whl"和“.tar.gz”的安装
示例:对于.whl结尾的文件,直接
pip install numpy-1.15.0-cp27-cp27mu-manylinux1_x86_64.whl
示例:对于下载的压缩包,解压后进入文件,找到“setup.py”文件,然后安装
python setup.py install
个人建议:
建议使用".whl"文件安装,不要使用".tar.gz"安装,因为".tar.gz"在编译过程中容易出错
centos的yum安装(如果yum安装有问题):
第一步:yum clean all清空缓存
第二步:yum makecache重新建立yum安装缓存