python自动化脚本报错:Message: Can not connect to the Service chromedriver

今天,我打开之前写的自动化脚本,自动打开网站登录的,结果发现运行的时候报错:
Traceback (most recent call last):
File “C:/Users/Administrator/Desktop/selenium脚本/创建端口号.py”, line 7, in
driver = webdriver.Chrome()
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\chrome\webdriver.py”, line 73, in init
self.service.start()
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\common\service.py”, line 104, in start
raise WebDriverException(“Can not connect to the Service %s” % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver
python自动化脚本报错:Message: Can not connect to the Service chromedriver
在网上找了一下解决办法,写的很多种,最后选择了一个很简单的一种
首先打开cmd,输入

ping localhost

发现一般故障,数据100%丢失
python自动化脚本报错:Message: Can not connect to the Service chromedriver
后来找的解决办法,是因为我上午因为用谷歌浏览器打不开一个地址,所以在Windows防火墙里添加了允许Chrome,结果就把防火墙打开了
解决办法:把Windows防火墙关闭
右键我的电脑,打开属性,打开控制面板主页,系统和安全,点击Windows防火墙,打开或关闭Windows防火墙,如下图
python自动化脚本报错:Message: Can not connect to the Service chromedriver
现在在cmd里输入ping localhost
python自动化脚本报错:Message: Can not connect to the Service chromedriver
发现正常了
这是再来允许python脚本,成功打开浏览器