Python has ValueError: check_hostname requires server_hostname and Read timed out when installing the package

一、ValueError: check_hostname requires server_hostname

This problem is basically caused by the opening of network agent software such as VPN, which can be solved by turning off the agent software.

2. Read timed out

When installing the python package, Read timed out appears. Although the image source py.ini and pip --default-timeout=100 install -U XXXX are added
, the same error occurs, as shown below:

Python review (3) - the solution to the Read timed out timeout that occurs when Python installs the package - Programmer Sought

Finally, I understand the reason for the error on the basis of other blogs: pip install package name is generally used, and the default choice is to download the package from Python’s official source pypi.python.org/pypi, which is similar to the R language prompt before loading the package The principle of choosing Lanzhou image or Beijing image package is very similar. Python packages are also stored in mirrors. Selecting an appropriate mirror official website can install python library packages more quickly.

solution

D:\Python\Anaconda>pip install keras -i https://pypi.tuna.tsinghua.edu.cn/simple/

Python review (3) - the solution to the Read timed out timeout that occurs when Python installs the package_Python Tutorial_02

Commonly used pip mirror paths are:

1. Aliyun (this image is not recommended, often can not find the package)

pip install package name -i http://mirrors.aliyun.com/pypi/simple/

2. University of Science and Technology of China
pip install package name -i https://pypi.mirrors.ustc.edu.cn/simple/

3. Douban
pip install package name -i http://pypi.douban.com/simple/

4. Tsinghua University
pip install package name -i https://pypi.tuna.tsinghua.edu.cn/simple/

5. University of Science and Technology of China
pip install package name -i http://pypi.mirrors.ustc.edu.cn/simple/

6. University of California
pip install package name -i https://www.lfd.uci.edu/~gohlke/pythonlibs/

Unifiedly execute cmd on the terminal as an administrator, and then enter the above command to complete the quick installation of the package.

Pycharm modifies Python's default download mirror

In addition to selecting the mirror image, it is particularly troublesome to replace the mirror image every time. If you choose a mirror image permanently, it will be done once and for all. Here the pycharm project is python_venu, open the settings of File

Python review (3) - the solution to the Read timed out timeout that occurs when Python installs the package_Python Development_03

 Then select project interpreter, enter the following interface, click the plus sign; enter the new management page:

Python review (3) - the solution to the Read timed out timeout that occurs when Python installs the package_Python Development_04

After entering the image loading management settings of the image package, click Manage Repositories to set the image:

Python review (3) - the solution to the Read timed out timeout that occurs when Python installs the package_Python Development_05

 After adding the mirrors that need to be used, set them up and delete the previous official website mirror path, as shown below:

Python review (3) - the solution to the Read timed out timeout that occurs when Python installs the package_Python Tutorial_06

Download the package later, and the installation package will be faster.

If the timeout occurs again, you can add the default time

Installation package method one: set the installation time on the online website

pip install tensorflow-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple/ --default-timeout=100

Installation package method 2: download and install offline

pip install C:\Users\Administrator\Desktop\test\rpy2-2.9.5-cp35-cp35m-win_amd64.whl

Installation package method three: online website installation

(venv) D:\Python\Python_venu>pip install https://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2/rpy2‑2.9.5‑cp35‑cp35m‑win_amd64.whl --default-timeout=100

use
 

`a = robjects.r('a<-c(1,2,3)') print(a)`
import rpy2.robjects as robjects

Guess you like

Origin blog.csdn.net/JineD/article/details/131716898