尝试在 python 脚本中将 Selenium 与 Chrome 结合使用。
我收到以下错误:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
我知道 chromedriver 可执行文件的位置。 如何将它添加到 PATH 中?
谢谢
最佳答案
您可以在脚本中指定 chrome 驱动程序的绝对路径:
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/path/to/driver/chromedriver')
或者您可以在 PATH
中添加网络驱动程序的路径系统变量如下:
export PATH=$PATH:/path/to/driver/chrome-driver
您可以将以上行添加到您的 /home/<user>/.profile
文件以使其永久化。
在运行 Python 2.7.14 的 Ubuntu 17.10 上测试
希望这对您有所帮助!
关于linux - 如何在 Linux 中将 Chromedriver 添加到 PATH?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48213384/