简体   繁体   English

selenium.common.exceptions.WebDriverException:消息:服务 chromedriver 意外退出

[英]selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited

I am aware of very similar questions having been asked already but even after a few hours of googling, researching and comparing I can't figure out what the problem is.我知道已经有人问过非常相似的问题,但即使经过几个小时的谷歌搜索、研究和比较,我也无法弄清楚问题是什么。 My ultimate goal is to do some web scraping with Python using selenium but for now I can't even get the webdriver to start.我的最终目标是使用 selenium 用 Python 进行一些网络抓取,但现在我什至无法启动 webdriver。 This is the code and the error message that I've got so far:这是到目前为止我得到的代码和错误消息:

$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyvirtualdisplay import Display
>>> from selenium import webdriver
>>> 
>>> display = Display(visible=0, size=(1024, 768))
>>> display.start()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '1024x768x24', ':1069'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '1024x768x24', ':1069'] oserror=None return_code=None stdout="None" stderr="None" timeout_happened=False>
>>> d = webdriver.Chrome()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 96, in start
    self.assert_process_still_running()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1

The chromedriver version is 2.30 and is located at: chromedriver 版本为 2.30,位于:

$ ll /usr/local/bin/chromedriver
-rwxr-xr-x 1 stefan stefan 8475456 Jun  7 15:53 /usr/local/bin/chromedriver

Since it's in /usr/local/bin I do not need to specify the path when instantiating the webdriver as in d = webdriver.Chrome("/path/to/chromedriver") .由于它在/usr/local/bin ,因此在实例化 webdriver 时不需要指定路径,如d = webdriver.Chrome("/path/to/chromedriver")

Before I was able to run above code I installed google Chrome browser, xvfb, pyvirtualdisplay and selenium.在我能够运行上面的代码之前,我安装了谷歌 Chrome 浏览器、xvfb、pyvirtualdisplay 和 selenium。 The commands I used where:我在其中使用的命令:

sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get install -f
sudo apt-get install xvfb
wget -N http://chromedriver.storage.googleapis.com/2.30/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/local/bin
sudo pip install pyvirtualdisplay selenium

So, I have the latest versions of all the software.所以,我拥有所有软件的最新版本。 Any help as to what the solution to my problem could be is greatly appreciated.非常感谢有关解决我的问题的方法的任何帮助。 Thank you very much in advance.非常感谢您提前。

Have got the same problem when I ran process with selenium and PhantomJs driver through nohup (Also mentioned there ) I needed to capture output in virtual machine and not depend on opened session.当我通过nohup使用 selenium 和 PhantomJs 驱动程序运行进程时遇到了同样的问题(也在那里提到)我需要在虚拟机中捕获输出而不依赖于打开的会话。

I started using tmux for that purpose which does not block signals like nohup does and the problem has disappeared.为此,我开始使用tmux ,它不会像 nohup 那样阻塞信号,并且问题已经消失。

将 chromedriver.exe 和您的程序放在同一目录中。

暂无
暂无

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

相关问题 Docker Selenium:selenium.common.exceptions.WebDriverException:消息:服务chromedriver意外退出。 状态码为:127 - Docker Selenium: selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127 selenium.common.exceptions.WebDriverException:消息:服务 chromedriver 意外退出。 状态码是:1 - selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1 selenium.common.exceptions.WebDriverException:消息:Linux 上的 ChromeDriver Selenium Python 服务 /usr/bin/google-chrome 意外退出 - selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited with ChromeDriver Selenium Python on Linux selenium.common.exceptions.WebDriverException:消息:chromedriver 意外退出。 状态码为:255 使用 Dockerfile 时 - selenium.common.exceptions.WebDriverException: Message: chromedriver unexpectedly exited. Status code was: 255 When using Dockerfile webDriverException“selenium.common.exceptions.WebDriverException:消息:Service./webdrivers/geckodriver 意外退出。状态代码为:1” - webDriverException "selenium.common.exceptions.WebDriverException: Message: Service ./webdrivers/geckodriver unexpectedly exited. Status code was: 1" selenium.common.exceptions.WebDriverException:消息:服务意外退出。 状态码为:3221225595 - selenium.common.exceptions.WebDriverException: Message: Service unexpectedly exited. Status code was: 3221225595 selenium.common.exceptions.WebDriverException:消息:服务geckodriver意外退出。 状态代码为:-11-如何解决? - selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: -11 - How to fix? selenium.common.exceptions.WebDriverException:消息:服务geckodriver意外退出。 状态码为:69 - selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 69 selenium.common.exceptions.WebDriverException:消息:Service.\geckodriver.exe 意外退出。 状态码为:3221225595 - selenium.common.exceptions.WebDriverException: Message: Service .\geckodriver.exe unexpectedly exited. Status code was: 3221225595 selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:使用ChromeDriver Chrome和Selenium异常退出 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM