本文介绍了如何在Linux中将Chromedriver添加到PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试在Python脚本中将Selenium与Chrome结合使用.
Trying to use Selenium with Chrome in a python script.
我收到以下错误:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see sites.google/a/chromium/chromedriver/home我知道chromedriver可执行文件的位置. 如何将其添加到PATH?
I know the location of the chromedriver executable. How do I add it to the PATH?
谢谢
推荐答案您可以在脚本中指定chrome驱动程序的绝对路径,如下所示:
You can specify the absolute path to your chrome driver in your script as such:
from selenium import webdriver driver = webdriver.Chrome(executable_path='/path/to/driver/chromedriver')或者您可以在PATH系统变量中将网络驱动器的路径添加为:
Or you can add the path to your webdriver in the PATH system variable as so:
export PATH=$PATH:/path/to/driver/chrome-driver您可以将以上行添加到您的/home/<user>/.profile文件中,以使其永久保存.
You may add the above line to your /home/<user>/.profile file to make it permanent.
在运行Python 2.7.14的Ubuntu 17.10上测试
Tested on Ubuntu 17.10 running Python 2.7.14
希望这会有所帮助!
更多推荐
如何在Linux中将Chromedriver添加到PATH?
发布评论