Use of pip, pip.ini file configuration, mirror source replacement
Article Directory
-
- Use of pip, pip.ini file configuration, mirror source replacement
-
-
- View all packages and versions installed in the current python environment
- pip detailed command usage
-
- pip package update upgrade
- pip install other packages
- Temporary use of a mirror source
- The configuration method of the pip.ini file:
- Modify the rules of the pip.ini file
- pip to see if it is installed
- pip checks which packages need to be updated
- pip upgrade package
- pip uninstall package
- pip parameter explanation
-
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.ini
set 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
[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
actual pathC:\Users\PC\AppData\Roaming
pip
Create a folder under this directory :
C:\Users\PC\AppData\Roaming\pip
Create files under pip
folderpip.ini
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-url
and trusted-host
the following content
Change to other mirror source addresses respectively
trusted-host
The content in is index-url
in域名部分
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:
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.ini
add it
trusted-host=pypi.douban.com
My previous trusted-host=pypi.douban.com
possibility 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
[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