用Pip來安裝Selenium Web Driver的python庫,命令為:pip install selenium
安裝完成后,運行python解釋器,執行命令import selenium,如果沒有異常,則表示安裝成功了
問題:
在安裝第三方庫的時候,Python報錯pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
當我們在用pip或者pycharm來安裝模塊的時候,經常會遇到ReadTimeout錯誤,造成這個問題的原因就是網速問題。我的解決方法有兩條,如下:
1.換個網絡連接重新下載
可以看到下面在cmd中用pip安裝的下載速度為幾十KB/S,這已經算不錯的速度。想想之前出現錯誤可都是幾KB/S
2.使用命令
pip --default-timeout=1000 install -U 模塊名
例如
pip --default-timeout=1000 install -U matplotlib
來下載matplotlib,讓它的延遲檢測時間變長。
pip --default-timeout=1000 install -U selenium
3.利用國內的其他鏡像源
清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
阿里雲 http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
下載安裝 selenium
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com selenium
https://blog.csdn.net/hahaxq/article/details/104120025