pip config

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/Hesy_H/article/details/102750921





win安装的坑

  • powershell不支持conda,请用cmd或者其他的 ( 或者安装插件
  • pip和conda总是会出现HTTPS error(连接超时了)
    • 先试试关掉proxy,不行的话就 ↓
  • 手动下载torch的whl进行安装




手动更改pip配置(win

(linux下就是pip.conf文件了

文件位置

  • 对于虚拟环境,pip.ini的位置是$VIRTUAL_ENV/pip.ini

  • 也支持site-wide的配置,路径是%HOME%\pip\pip.ini 我电脑上则是 %APPDATA%\pip.ini

多个文件配置并存的优先级:
在这里插入图片描述
数字越大等级越高( 后面的覆盖前面的



配置原理

ref @ 官网

  • 配置文件里面的设置名称来源于长命令行选项,例如 如果要使用其他程序包索引(–index-url)并将HTTP超时(–default-timeout)设置为60秒,则配置文件将如下所示:
[global]
timeout = 60
index-url = https://download.zope.org/ppix
  • 这里的 [global] 指的是默认的命令配置。每个子命令都可以在其自己的session中进行配置,以便覆盖具有相同名称的每个全局设置。 例如 通过运行以下命令可以将超时减少到10秒:freeze,而对所有其他命令使用60秒可以通过以下方式进行:
[global]
timeout = 60

[freeze]
timeout = 10

在这里插入图片描述
注意,这里的源得是https,不然会出现报错

在这里插入图片描述
然后每次都得添加 - -trusted-host=pypi.doubanio.com

  • 要么把http改成https,要么加上trusted-host




常用参数

-i 指定源

-i, --index-url
Base URL of the Python Package Index (default https://pypi.org/simple). This should point to a repository compliant with PEP 503 (the simple repository API) or a local directory laid out in the same format.



-f 既可以指定下载地址又可以指定本地地址 (用于本地whl安装的时候

-f, --find-links
If a url or path to an html file, then parse for links to archives. If a local path or file:// url that’s a directory, then look for archives in the directory listing.

猜你喜欢

转载自blog.csdn.net/Hesy_H/article/details/102750921