简体   繁体   English

Python / Selenium - “chromedriver”可执行文件需要在路径中

[英]Python / Selenium - “chromedriver” executable needs to be in a PATH

I was trying to do something with a gecko driver ( Selenium in this case ) and I can't get my chrome driver to work.我试图用壁虎驱动程序(在这种情况下为 Selenium)做一些事情,但我无法让我的 chrome 驱动程序工作。 Knowing that I am on Mac Sierra, and that my script is in the same folder as my chrome driver, here is my code知道我在 Mac Sierra 上,并且我的脚本与我的 chrome 驱动程序在同一个文件夹中,这是我的代码


from selenium import webdriver
import time

url = "https://accounts.google.com/signup/v2/webcreateaccount?flowName=GlifWebSignIn&flowEntry=SignUp"
driver = webdriver.Chrome("chromedriver")
driver.get(url)

Thanks for the help谢谢您的帮助

Try this:尝试这个:

from selenium import webdriver


driver= webdriver.Chrome(executable_path="C:/users/usr/Desktop/chromedriver.exe")

url = 'your website'

driver.get(url)

make sure you are using this slash (/) in your file path to the chrome driver (as shown above)确保您在 chrome 驱动程序的文件路径中使用此斜杠 (/)(如上所示)

You can test if it actually is in the PATH, Open your command prompt go to the location of your chromedriver and hit enter.您可以测试它是否真的在 PATH 中,打开命令提示符 go 到您的 chromedriver 的位置,然后按 Enter。 you will get below message:您将收到以下消息:

C:\>
chromedriver.exe
Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-ref
s/branch-heads/3809@{#864}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent
 access by malicious code.

Then you need to setup PATH like below before you start your test:然后你需要在开始测试之前像下面这样设置 PATH:

driver = webdriver.Chrome('/path/to/chromedriver') 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 'chromedriver' 可执行文件需要在 PATH 中 - Python - Selenium (MAC) - 'chromedriver' executable needs to be in PATH - Python - Selenium (MAC) 在 Selenium/Python 中出错 - chromedriver 可执行文件需要在 PATH 中 - Getting Error in Selenium/Python - chromedriver executable needs to be in PATH Headless Python Selenium 显示错误 'chromedriver' 可执行文件需要在 PATH 中 - Headless Python Selenium Shows Error 'chromedriver' executable needs to be in PATH WebDriverException:消息:“chromedriver”可执行文件需要在 PATH 中,同时通过 Selenium Chromedriver python 设置 UserAgent - WebDriverException: Message: 'chromedriver' executable needs to be in PATH while setting UserAgent through Selenium Chromedriver python 'chromedriver' 可执行文件需要在 Python Django 的 PATH 中 - 'chromedriver' executable needs to be in PATH in Python Django chromedriver 的可执行文件需要在 PATH 中 - chromedriver' executable needs to be in PATH 消息:在Web服务器上执行python硒时,'chromedriver'可执行文件需要位于PATH中 - Message: 'chromedriver' executable needs to be in PATH while executing python selenium on web server 如何修复 Selenium 错误(Python) - 消息:“chromedriver.exe”可执行文件需要在 PATH 中 - How to fix Selenium Error (Python) - Message: 'chromedriver.exe' executable needs to be in PATH Selenium WebDriverException:消息:“ chromedriver.exe”可执行文件必须位于PATH中 - Selenium WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要在 PATH 中 - selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM