Machine Learning Notes

anaconda use

  • View all virtual environments
conda info -e (查看所有的虚拟环境)
conda info --envs
conda env list
activate -name(虚拟环境名字)(进入到该虚拟环境中)
  • delete environment
conda remove -n xxxxx(名字) --all

Explanation: removeIndicates deletion, -nyes ( namethe abbreviation of the name), xxxxx is the name of the virtual environment to be deleted, if the last one is -–allnot added, it means that a package in the current environment is deleted, such as numpy, etc., if it is added, it is Delete the virtual environment

  • Create a new virtual environment
conda create -n xxxxx(名字) python=3.8

Explanation: createIt means to create, -nit is (the abbreviation of name name), xxxxx is the name of the virtual environment created, python=3.8indicating that the interpreter of python3.8 is configured for this virtual environment

  • Enter the virtual environment
activate  xxxxx(名字)
  • Check out the virtual environment's library
pip list
  • Exit the virtual environment
deactivat
  • Exit the current base environment
conda deactivate

Solve the error reported by SSL when pip installs third-party packages

insert image description here

What is SSL?

Transport Layer Security (English: Transport Layer Security, TLS) and its predecessor Secure Sockets Layer (English: Secure Sockets Layer, SSL) is a security protocol in the current HTTPS protocol, the purpose is to provide security and data security for Internet communications. Integrity guarantee
The built-in pip of the newer version of python and the requests and urllib3 packages for network requests are also newer, and will use the HTTPS protocol to download new packages

Why is there an error

According to the error message, it can be found that the root of the error lies in SSL, that is, the failure to pass the authentication of the security protocol, usually due to the opening of software such as network proxy, VPN or network capture

Solution

  1. Temporarily close software such as proxy, VPN or network capture

    The most recommended way is to temporarily close software such as proxy, VPN or network capture software, but if the download speed is too slow after closing, you can try the latter two solutions

  2. Avoid SSL authentication problems through mirrored HTTP sources.
    Since SSL is required by the HTTPS protocol, we can switch to HTTP mirror sites for installation and download.
    HTTPS is now more popular, and many mirror sources have already switched to the HTTPS protocol. , but some mirror sources support the HTTPS protocol as well as the HTTP protocol. The following is a brief list of several pip mirror sources

# 清华,仅支持 HTTPS
https://pypi.tuna.tsinghua.edu.cn/simple/

# 阿里,HTTP 和 HTTPS 均支持
http://mirrors.aliyun.com/pypi/simple/
https://mirrors.aliyun.com/pypi/simple/

# 豆瓣,HTTP 和 HTTPS 均支持
http://pypi.doubanio.com/simple/
https://pypi.doubanio.com/simple/

When installing third-party packages, you can refer to the following commands:

pip install xxx-package -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install xxx-package -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com

If you want to use the mirror station permanently, you need to modify the configuration file, taking Linux as an example:

vim ~/.pip/pip.conf

The modified content is as follows

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host = mirrors.aliyun.com
  1. Switch to a lower version of pip
    After testing, this error will only occur when the pip version is higher than 20.3, so we can manually downgrade the pip version to a lower version such as 20.2.4 or 20.3b1
python -m pip install pip==20.2.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
python -m pip install pip==20.2.4 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com

Guess you like

Origin blog.csdn.net/qq_43200940/article/details/129946307