文章目录

  • 换源
    • pip 国内的一些镜像
    • 修改源方法:
    • conda 换源
  • 用法总览
  • 一、安装 & 移除
    • 安装指定包的最新版
    • 安装制定包的指定版本
    • 移除指定包
    • 在 PyPI 上模糊查找相关包
  • 二、查看相关
    • 查看所有已安装的包
    • 查看指定包的相关信息
  • 三、更新相关
    • 更新 pip
    • 更新包
  • 四、freeze 的使用
    • 列出所有已安装包
    • 生成 requirements.txt 文件
  • 五、遇到的异常及解决
    • PermissionError: [WinError 5] 拒绝访问
  • REFERENCES

换源

第一件事当然是换源 ~

pip 国内的一些镜像

阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

修改源方法:

临时使用:
可以在使用pip的时候在后面加上-i参数,指定pip源

eg: pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

永久修改:

LInux系统
修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

Windows:
win+R 打开用户目录%HOMEPATH%,在此目录下创建 pip 文件夹,在 pip 目录下创建 pip.ini 文件, 内容如下:

[global]timeout = 6000index-url = https://pypi.tuna.tsinghua.edu.cn/simpletrusted-host = pypi.tuna.tsinghua.edu.cn
conda 换源

添加清华的镜像源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
conda - -help // 找到配置文件.condarc 的路径 ,将上述显示的配置信息中 - defaults 所在行删除保存即可

查看源:

conda config --show channels

换回默认源

conda config --remove-key channels

用法总览

pip3 --help
Usage:   pip <command> [options]Commands:install                     Install packages.download                    Download packages.uninstall                   Uninstall packages.freeze                      Output installed packages in requirements format.list                        List installed packages.show                        Show information about installed packages.check                       Verify installed packages have compatible dependencies.search                      Search PyPI for packages.wheel                       Build wheels from your requirements.hash                        Compute hashes of package archives.completion                  A helper command used for command completion.help                        Show help for commands.General Options:-h, --help                  Show help.--isolated                  Run pip in an isolated mode, ignoring environment variables and userconfiguration.-v, --verbose               Give more output. Option is additive, and can be used up to 3 times.-V, --version               Show version and exit.-q, --quiet                 Give less output. Option is additive, and can be used up to 3 times(corresponding to WARNING, ERROR, and CRITICAL logging levels).--log <path>                Path to a verbose appending log.--proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.--retries <retries>         Maximum number of retries each connection should attempt (default 5 times).--timeout <sec>             Set the socket timeout (default 15 seconds).--exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe,(b)ackup, (a)bort.--trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.--cert <path>               Path to alternate CA bundle.--client-cert <path>        Path to SSL client certificate, a single file containing the private key andthe certificate in PEM format.--cache-dir <dir>           Store the cache data in <dir>.--no-cache-dir              Disable the cache.--disable-pip-version-checkDon't periodically check PyPI to determine whether a new version of pip isavailable for download. Implied with --no-index.

一、安装 & 移除

安装指定包的最新版
pip3 install pkg_name
安装制定包的指定版本
pip3 install pkg_name==version$ pip3 install django==2.0.5
移除指定包
pip3 uninstall pkg_name
在 PyPI 上模糊查找相关包
pip3 search pkg_name

二、查看相关

查看所有已安装的包
pip3 list形如:
amqp (1.4.9)
anyjson (0.3.3)
asn1crypto (0.24.0)
查看指定包的相关信息
pip3 show pkg_name$ pip3 show django
Name: Django
Version: 2.1.4
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: foundation@djangoproject.com
License: BSD
Location: /home/ezreal/.local/lib/python3.6/site-packages
Requires: pytz

三、更新相关

更新 pip

在 Anaconda prompt 环境下

conda upgrade pip

普通环境

python -m pip install --upgrade pip
更新包

检查哪些包需要更新

pip list --outdated

更新指定包

pip install --upgrade pkg_name

四、freeze 的使用

列出所有已安装包
pip3 freeze形如:
vine==1.1.4
virtualenv==16.1.0
youtube-dl==2018.9.10
生成 requirements.txt 文件
  • 将当前 Python 环境下所有类库导出生成为 requirements.txt
pip3 freeze > requirements.txt
  • 将特定项目使用的类库导出生成为 requirements.txt(其中.为当前文件夹下的项目,可改成你项目的路径)
# 需要安装第三方库
pip3 install pipreqs# .表示当前目录
pipreqs . --encoding=utf8
  • 安装 requirements.txt 依赖
pip3 install -r requirements.txt

五、遇到的异常及解决

PermissionError: [WinError 5] 拒绝访问


解决:加上--user参数

pip install --user --upgrade tensorflow-gpu

REFERENCES

[1] PIP 更换国内安装源:https://blog.csdn.net/yuzaipiaofei/article/details/80891108

pip3 常见用法总结相关推荐

  1. python propresql mysql_python数据库操作mysql:pymysql、sqlalchemy常见用法详解

    本文实例讲述了python数据库操作mysql:pymysql.sqlalchemy常见用法.分享给大家供大家参考,具体如下: 相关内容: 使用pymysql直接操作mysql 创建表 查看表 修改表 ...

  2. mysql中正则表达式的用法_Mysql中正则表达式Regexp常见用法

    Mysql中Regexp常见用法 模糊匹配,包含特定字符串 # 查找content字段中包含"车友俱乐部"的记录 select * from club_content where ...

  3. python六:常见数据类型以及常见用法

    bool 布尔值 # 在bool中 0,()(空元祖),[](空列表),{}(空字典),None,""(空字符串) 都是False int 整形 float 浮点型 str 字符串 ...

  4. vue-router 的常见用法

    vue-router 的常见用法 1. 路由重定向 路由重定向指的是:用户在访问地址 A 的时候,强制用户跳转到地址 C ,从而展示特定的组件页面. 通过路由规则的 redirect 属性,指定一个新 ...

  5. 空的宏定义作用及常见用法

    空的宏定义作用及常见用法 我们学习宏定义的第一个概念是,宏定义作为替换作用. 例如: #define SIZE 32 // 接下来代码使用SIZE就相当于32 宏定义是编译器在编译时,将程序中所有SI ...

  6. Arrays常见用法

    Arrays常见用法

  7. sed文本处理常见用法

    sed文本处理常见用法    2011-06-24  TsengYia#126.com http://tsengyia.blog.chinaunix.net/   ################## ...

  8. typeset的常见用法

    [保留] typeset的常见用法 http://www.chinaunix.net 作者:寂寞烈火  发表于:2007-12-16 09:50:34 [发表评论] [查看原文] [Shell讨论区] ...

  9. 框架前期准备篇之AutoFac常见用法总结 转载

    框架前期准备篇之AutoFac常见用法总结 一. 说在前面的话 凡是大约工作在两年以上的朋友们,或多或少都会接触到一些框架搭建方面的知识,只要一谈到框架搭建这个问题或者最佳用法这个问题,势必会引起一点 ...

最新文章

  1. 中国电子学会图形化四级编程题:解密
  2. python 编程入门-Python编程入门电子书教程,看这几个就够了
  3. 关于JAVA中URL传递中文参数,取值是乱码的解决办法
  4. 03、动态代理--CGLib引入增强
  5. 文件方式实现完整的英文词频统计实例(9.27)
  6. .NET Core 3.0中的新功能和增强功能
  7. 【转】如何把Matlab中的m文件转化成C语言代码
  8. 404错误、500错误、异常错误提示页面的拦截和自定义
  9. 【JavaScript知识点五】javascript 流程语句
  10. 迎来智能数据分析的新时代
  11. android 网易视频无法播放器,如何使用网易视频云播放器Android Demo
  12. 【前端杂记】断点续传
  13. Using SVN with Ant
  14. 在 SSM 中使用 Ajax 进行数据传递
  15. 美国经济数据公布时间
  16. 记《浪潮之巅》-第一版-6.IT业的罗马帝国--微软,Microsoft
  17. SRP Batcher:提升您的渲染性能
  18. VirtualBox安装教程和ubuntu16导入
  19. 教 你 如 何 唱 歌
  20. 生成微信支付二维码及微信支付

热门文章

  1. win10开机报错0xc0000098,bcd文件损坏无法正常启动,全网最简单的修复方法,这里不得不说老毛桃的强大了
  2. python实现AC自动机
  3. vos3000外呼系统根据被叫手机号码归属地进行优先路由线路
  4. 第一款基于GPT4的手机APP来啦,一键解读图片,颠覆生活
  5. 用CMD方法彻底禁止端口占用方法
  6. 使用广泛的pdf分割软件
  7. 灰度数据表示(为什么要除255)
  8. 在AWS云服务器上部署Docker,并使用Docker部署ownCloud私有云盘
  9. 【老生谈算法】matlab实现用CZT求解系统函数的零极点——零极点
  10. 二叉树的前序中序后序遍历真题