使用pip安装Selenium。
试图运行以下代码:
import selenium
from selenium import webdriver
\#driver = webdriver.Chrome()
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
time.sleep(5)
driver.quit()我得到的是:
python 5格式刮-selenium.py 回溯(最近一次调用): 文件“5 formscrap-selenium.py”,第5行,在driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')中 文件"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py",第62行,在init self.service.start()中 文件"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py",第81行,在start os.path.basename(self.path),self.start_error_message) selenium.common.exceptions.WebDriverException:消息中:“chromedriver”可执行文件需要在路径中。请参阅https://sites.google.com/a/chromium.org/chromedriver/home
$PATH包含/usr/bin/chromedriver
色驱动程序文件在/usr/bin中具有特权。
sudo chmod a*x chromedriver 所以我在这里错过了什么?
发布于 2017-08-13 14:37:46
chromdriver需要在PATH中,意味着它存在的目录应该在PATH中,而不是整个路径本身。变化
$PATH=/usr/bin/chromedriver:....至
$PATH=/usr/bin/:....删除显色剂,这样selenium可以在chromedriver中搜索/usr/bin
https://stackoverflow.com/questions/45661271
复制相似问题