Using Python error urlopen error unknown URL type: the solution of HTTPS

Analysis

This error has something to do with the SSL (secure sockets layer, an international standard communication protocol for encryption and identity authentication) module in Python. If you successfully install the SSL module, you can solve this problem.

resolvent

Windows system is slightly different from other UNIX like systems, but you can confirm whether SSL module is installed in the python version you are using. In the python environment, use the following command to view the installed module:

help("modules")

According to the official documents of python, SSL is a module used for network and interprocess communication in the python standard library. The Windows version of Python installation program usually includes the whole standard library, and even additional components. Other UNIX like operating systems are divided into a series of software packages, and some or all components may need to be installed through the package management tool.

Windows system

Because the Windows version of Python installation program contains SSL module, check whether the environment variables are set well.

If anaconda is used, because it already contains python, check the SSL in the installed module, and then check whether the following environment variables are added completely.

InstallPath              #Assuming InstallPath is your installation path
InstallPath\Scripts      
InstallPath\Library\bin

If there is no SSL module, or there is no problem with the above operations, and an error is still reported, you can try to re install python.

UNIX like operating system

After the default installation, the functions related to SSL cannot be used normally, and the corresponding parameters need to be added when checking the configuration before compilation.

# Add the --with-ssl parameter when installing python
./configure --prefix=/usr/local/python37 --with-ssl

Read More: