pip and conda package manager

pip is the most widely used Python package manager

Can help us get the latest Python package and manage it. Commonly used commands are as follows:

pip install [package-name]              # 安装名为[package-name]的包
pip install [package-name]==X.X         # 安装名为[package-name]的包并指定版本X.X
pip install [package-name] --proxy=代理服务器IP:端口号         # 使用代理服务器安装
pip install [package-name] --upgrade    # 更新名为[package-name]的包
pip uninstall [package-name]            # 删除名为[package-name]的包
pip list                                # 列出当前环境下已安装的所有包

Replace the domestic mirror source

temporary

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple [package-name] 

Permanent modification

1. Under Linux

Modify ~/.pip/pip.conf (create a folder and file if you don’t have it. Add "." to the folder to indicate a hidden folder)
as follows:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

2. Under windows

Create a pip directory directly in the user directory, and then create a new file pip.ini. (For example: C:\Users\WQP\pip\pip.ini) The content is the same as above.

The conda package manager is Anaconda's own package manager

It can help us easily install various packages in conda environment. Compared with pip, conda is more versatile (not only Python packages, other packages such as CUDA Toolkit and cuDNN can also be installed), but the version update of conda source is often slower. Commonly used commands are as follows:

conda install [package-name]        # 安装名为[package-name]的包
conda install [package-name]=X.X    # 安装名为[package-name]的包并指定版本X.X
conda update [package-name]         # 更新名为[package-name]的包
conda remove [package-name]         # 删除名为[package-name]的包
conda list                          # 列出当前环境下已安装的所有包
conda search [package-name]         # 列出名为[package-name]的包在conda源中的所有可用版本

Change source

1. Windows

Choose between Tsinghua source and Zhongke University source
directly use the following command in the command line

#1 清华源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 
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/cloud/msys2/
# 设置搜索时显示通道地址
 
conda config --set show_channel_urls yes


# 2 添加中科大源
 
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
 
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
 
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
 
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
 
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
 
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
 
 
 
conda config --set show_channel_urls yes

2. Under Linux

Write the above configuration file in ~/.condarc

vim ~/.condarc

 
channels:
 
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
 
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
 
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 
  - defaults
 
show_channel_urls: true

Delete source

Switch back to the default source of conda. After reviewing the conda config documentation, it is found that channels can be deleted directly.

conda config --remove-key channels

Guess you like

Origin blog.csdn.net/weixin_42764932/article/details/113032188