Use of pip, pip.ini file configuration, mirror source replacement

Use of pip, pip.ini file configuration, mirror source replacement

View all packages and versions installed in the current python environment

Divided into pip view and conda view

pip:pip freeze

conda:conda list

pip detailed command usage

pip package update upgrade
pip -m pip install --upgrade pip
pip install other packages
pip install 安装的包名

Because I have already pip.iniset the configuration in the file to Douban source (download is fast), so there is no need to add it later -i 某某源地址. This method is to temporarily use a certain mirror source
insert image description here

[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
Temporary use of a mirror source
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 安装包名
Domestic installation sources:

University of Science and Technology of China: https://pypi.mirrors.ustc.edu.cn/simple

Tsinghua: https://pypi.tuna.tsinghua.edu.cn/simple

Douban: http://pypi.douban.com/simple/

Huazhong University of Science and Technology: http://pypi.hustunique.com/simple

Shandong University of Technology: http://pypi.sdutlinux.org/simple

Alibaba Cloud http://mirrors.aliyun.com/pypi/simple/

The configuration method of the pip.ini file:

Open cmd, enter into %APPDATA%the
insert image description here
actual pathC:\Users\PC\AppData\Roaming

pipCreate a folder under this directory :

C:\Users\PC\AppData\Roaming\pip

Create files under pipfolderpip.ini
insert image description here

Modify the rules of the pip.ini file
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com

Distributed trust configuration can be carried out, such as using Douban source, only trusting when downloading, but not trusting at other times, you can follow the above writing method (very invalid and 2)

So it is recommended to configure [global]in

as follows:

[global]
index-url = http://pypi.douban.com/simple
trusted-host=pypi.douban.com

If you want to change the mirror source, you only need to modify index-urland trusted-hostthe following content

Change to other mirror source addresses respectively

trusted-hostThe content in is index-urlin域名部分

pip to see if it is installed
# pip show --files 安装包名
 Name:SomePackage    # 包名
 Version:1.0         # 版本号
 Location:/my/env/lib/pythonx.x/site-packages   # 安装位置
 Files:              # 包含文件等等
  ../somepackage/__init__.py
  [...]
pip checks which packages need to be updated
pip list --outdated
Encounter problems:

insert image description here
Now the latest pip requires that the source must be https, otherwise an error will be reported:

WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.douban.com'.

But every time it is very geek to add such a long tail, pip.iniadd it

trusted-host=pypi.douban.com
insert image description here
My previous trusted-host=pypi.douban.compossibility is limited to medium install, that is, only when downloading is trusted

But still don’t trust when updating: [install]comment out or delete, so that the scope of trust is global
insert image description here

[global]
index-url = http://pypi.douban.com/simple
trusted-host=pypi.douban.com
pip upgrade package
pip install --upgrade 要升级的包名
pip uninstall package
pip uninstall --upgrade 要升级的包名
pip parameter explanation
pip --help

Guess you like

Origin blog.csdn.net/ahahayaa/article/details/127482313