[笔记] 配置python pip

来源:互联网 发布:淘宝关键词提取器 编辑:程序博客网 时间:2024/06/01 08:01

★ pip配置文件的位置

  • Linux中 : ~/.pip/pip.conf

  • Windows中: %HOMEPATH%\pip\pip.ini, 一般是C:\Users\<your_name>\pip\pip.ini

★ 修改pip配置

  • Linux中
vim ~/.pip/pip.conf

输入内容:

[global]index-url = http://mirrors.ustc.edu.cn/pypi/web/simpletimeout = 60[install]trusted-host = mirrors.ustc.edu.cn
  • Windows中

打开%HOMEPATH%\pip\pip.ini,输入内容同上面Linux中的配置.

★ 验证配置是否生效

通过pip install --help可以看到--index-url的默认值已经改成http://mirrors.ustc.edu.cn/pypi/web/simple:

  -i, --index-url <url>       Base URL of Python Package Index (default http://mirrors.ustc.edu.cn/pypi/web/simple).   --timeout <sec>             Set the socket timeout (default 60.0 seconds).

★ 其他参数

可以通过pip install --help看到pip install用到的参数,例如设置代理proxy, 可以将参数写到pip配置文件中,这样就不用在命令行指定了.

原创粉丝点击