The python automation script reports an error: Message: Can not connect to the Service chromedriver

Today, I opened the automated script I wrote before and automatically opened the website to log in. I found that an error was reported when running:
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/selenium script/create port number.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
Insert picture description here
I found a solution on the Internet and wrote many kinds of solutions. Finally, I chose a very simple one.
First, open cmd and enter

ping localhost

I found a general failure and 100% of the data was lost
Insert picture description here
. The solution I found later was because I couldn’t open an address with Google Chrome in the morning, so I added Allow Chrome to the Windows firewall. As a result, the firewall was turned on.
Solution: Windows Firewall is turned off
Right click on my computer, open properties, open the control panel homepage, system and security, click on Windows firewall, turn on or off Windows firewall, as shown
Insert picture description here
in the figure below. Now enter ping localhost in cmd and
Insert picture description here
find that
it is normal. This is to allow python script again, and successfully opened Browser

Guess you like

Origin blog.csdn.net/shenshenruoxi/article/details/105659101