Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
136 views
in Technique[技术] by (71.8m points)

python - unknown error: chrome failed to start

I've been stuck for days because of this issue and can't seem to find a solution. I can't get the chromedriver to work on my machine, no matter what I do. I've tried pretty much every setup I could possibly imagine. To list a few:

  • Chrome 64 bits, Python 64 bits
  • Chrome 32 bits, Python 32 bits
  • Chrome 64 bits, Python 32 bits
  • Chrome 32 bits, Python 64 bits

I've also tried different versions of Chrome with their corresponding chromedriver versions. I've tried different prior versions of selenium, and that is, on every previously mentioned setups.

For an actual context, here's my current setup:

  • Windows 10 Professional x64
  • Python 3.6.3 64 bits
  • Selenium 3.7.0
  • Google Chrome 62.0.3202.75 64 bits
  • Chromedriver 2.33

I will not post my code as no matter which code I use, it fails. Even the simplest most basic code that launches a chromedriver will not work. Also, it works on my colleague's machine. So to give some context, here's a code snippet I've tried that doesn't work:

from selenium import webdriver

webdriver.Chrome(executable_path="bin/chromedriver.exe")

I've also tried to add the chromedriver to my PATH and launching the chromedriver with no arguments but this doesn't work either.

The error I'm getting is this one:

selenium.common.exceptions.WebDriverException: Message: unknown error: chrome failed to start
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64)

And here's the log that gets generated if I launch the driver with the verbose/logging parameters:

[1.979][INFO]: COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "browserName": "chrome",
         "goog:chromeOptions": {
            "args": [  ],
            "extensions": [  ]
         },
         "platformName": "any"
      },
      "firstMatch": [ {

      } ]
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "goog:chromeOptions": {
         "args": [  ],
         "extensions": [  ]
      },
      "platform": "ANY",
      "version": ""
   }
}
[1.985][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "show_welcome_page": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[1.989][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[2.004][INFO]: Cannot switch to US keyboard layout - some keys may be interpreted incorrectly
[2.004][INFO]: Launching chrome: "C:Program Files (x86)GoogleChromeApplicationchrome.exe" --disable-background-networking --disable-browser-side-navigation --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --load-extension="C:UsersOLIVIE~1.VERAppDataLocalTempscoped_dir9668_31484internal" --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12606 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir="C:UsersOLIVIE~1.VERAppDataLocalTempscoped_dir9668_609" data:,
[2.035][INFO]: RESPONSE InitSession unknown error: chrome failed to start
[2.035][DEBUG]: Log type 'driver' lost 0 entries on destruction
[2.035][DEBUG]: Log type 'browser' lost 0 entries on destruction

I've had a look at pretty much every similar questions I could find, like this one, and this one for example, and none of the solutions I've came across helped, it's always the same error I get. I've been having the same error with the dozen of different setups I've tried.

A few months ago I remember I successfully ran the chromedriver for another project on the same machine.

I think I've provided all the necessary information, but don't hesitate to ask me in comments if I forgot something.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The error says it all Cannot switch to US keyboard layout - some keys may be interpreted incorrectly. This error have introduced some more errors as:

[2.035][INFO]: RESPONSE InitSession unknown error: chrome failed to start
[2.035][DEBUG]: Log type 'driver' lost 0 entries on destruction
[2.035][DEBUG]: Log type 'browser' lost 0 entries on destruction

So basically this error is not of Selenium or Chrome as such.

Here are the 3 best possible solutions to your problem.


Update :

As you have got rid of the error Cannot switch to US keyboard layout - some keys may be interpreted incorrectly but you still see WebDriverException: Message: unknown error: chrome failed to start follow the steps as below :

  1. Uninstall Chrome through Revo Uninstaller with Moderate Memory Scan so that the unwanted registry entries are cleared.
  2. Run CCleaner tool before and after executing your Tests to wipe off all the OS chores.
  3. Reboot your system.
  4. Execute your Test as:

    driver=webdriver.Chrome(executable_path=r'C:pathochromedriver.exe')
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...