python怎么用pip安装库 |
您所在的位置:网站首页 › python安装包慢 › python怎么用pip安装库 |
python怎么用pip安装库? 使用pip安装python库的几种方式 操作系统 : CentOS7.5.1804_x64 Python 版本 : 3.6.8 推荐:《Python教程》 1、使用pip在线安装 1.1 安装单个package 格式如下: pip install SomePackage登录后复制示例如下: 比如:pip install scipy 或者指定版本安装:pip install scipy==1.3.0 1.2 安装多个package 示例如下: pip install -r req.txt登录后复制req.txt 可以通过以下命令获取: pip freeze > req.txt登录后复制1.3 在线安装的其它问题 1.3.1 代理问题 如果需要通过代理安装,可以使用如下格式: pip --proxy=ip:port install SomePackage登录后复制1.3.2 pip源问题 如果pip源太慢,可以更换pip源,有以下两种方式: 方式一:通过修改参数临时修改pip源 比如使用阿里云的pip源: pip install Sphinx -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com登录后复制方式二:通过修改配置文件永久修改pip源 文件: ~/.pip/pip.conf 比如使用阿里云的pip源: [admin@localhost .pip]$ cat ~/.pip/pip.conf [global] index-url = http://mirrors.aliyun.com/pypi/simple/ extra-index-url=http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com [admin@localhost .pip]$登录后复制也可以使用自建pip源,或者其它公开pip源,比如: 阿里云 http://mirrors.aliyun.com/pypi/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/ Windows对应文件: C:\Users\用户名\AppData\Roaming\pip\pip.ini登录后复制2、从源码安装 示例如下: git clone https://github.com/sphinx-doc/sphinx cd sphinx pip install .登录后复制3、从 whl 文件安装 格式如下: pip install SomePackage.whl登录后复制其它 1、pip下载离线安装包 命令示例: 下载命令: pip download -d /tmp/packs -r requirement.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com登录后复制安装命令: pip install --no-index --find-links=/tmp/packs -r requirement.txt登录后复制以上就是python怎么用pip安装库的详细内容,更多请关注php中文网其它相关文章! |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |