问题如下:

/usr/bin/python2.7 /media/hao/000804B800006CAD/2018/BG/CODE/HaoCodes/Spider/baidu-music-spider-master/baidu-music-spider-master/testcase/login163.py
Traceback (most recent call last):
File "/media/hao/000804B800006CAD/2018/BG/CODE/HaoCodes/Spider/baidu-music-spider-master/baidu-music-spider-master/testcase/login163.py", line 19, in <module>
driver = webdriver.Chrome()
File "/home/hao/.local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/home/hao/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1

 

解决办法:

提示chrome driver没有放置在正确的路径下,于是下载chrome dirver,然后放置到/usr/bin的目录下,再次运行就OK了! 

OS

Expected Location of Chrome

Linux

/usr/bin/google-chrome1

Mac

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

Windows XP

%HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe

Windows Vista

C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe

需要根据自己的chrome浏览器版本,来下载对应版本相应包,我的版本师62,所以下载2.35版本,如下:

【Python】爬虫问题解决_ide

 

​https://chromedriver.storage.googleapis.com/index.html?path=2.35/​

chrome浏览器路径:/opt/google/chrome/chrome

安装selenium:pip install selenium

【Python】爬虫问题解决_ide_02

chrome driver下载路径:​​http://chromedriver.chromium.org/downloads​

 

赠人玫瑰
手留余香

我们曾如此渴望命运的波澜,到最后才发现:人生最曼妙的风景,竟是内心的淡定与从容……我们曾如此期盼外界的认可,到最后才知道:世界是自己的,与他人毫无关系!-杨绛先生

如果,您希望更容易地发现我的新博客。