title: Python selenium - Not working in Ubuntu
body: <p>Below is the code snippet of what I am running on Ubuntu 16.04.</p>
  
  <pre><code>    from selenium import webdriver
      from selenium.webdriver.chrome.options import Options
      path_to_chromedriver = '/usr/local/bin/chromedriver' # change path as needed
      options = webdriver.ChromeOptions()
      options.add_argument("start-maximized")
      options.add_argument('--disable-extensions')
      options.add_argument('--headless')
      options.add_argument('--disable-gpu')
      options.add_argument('--no-sandbox') 
      options.add_argument('--no-sandbox')
      service_log_path = "{}/chromedriver.log".format('/tmp/local/')
      service_args = ['--verbose']
      driver = webdriver.Chrome(executable_path = path_to_chromedriver,chrome_options=options,
              service_args=service_args,
              service_log_path=service_log_path)
  </code></pre>
  
  <p>Doesnt matter what flag I put, I always get below error in chromedriver.log file.</p>
  
  <pre><code>[1.001][INFO]: COMMAND InitSession {
     "capabilities": {
        "alwaysMatch": {
           "browserName": "chrome",
           "goog:chromeOptions": {
              "args": [ "--headless", "--no-sandbox" ],
              "extensions": [  ]
           },
           "platformName": "any"
        },
        "firstMatch": [ {
  
        } ]
     },
     "desiredCapabilities": {
        "browserName": "chrome",
        "goog:chromeOptions": {
           "args": [ "--headless", "--no-sandbox" ],
           "extensions": [  ]
        },
        "platform": "ANY",
        "version": ""
     }
  }
  [1.001][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_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.001][INFO]: Populating Local State file: {
     "background_mode": {
        "enabled": false
     },
     "ssl": {
        "rev_checking": {
           "enabled": false
        }
     }
  }
  [1.001][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --full-memory-crash-report --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.np7aOC/internal --logging-level=1 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12652 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.iUR4hY data:,
  [1.001][DEBUG]: DevTools request: http://127.0.0.1:12652/json/version
  [1.002][WARNING]: PAC support disabled because there is no system implementation
  [927:927:0316/063553.173763:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
  
  [1.037][DEBUG]: DevTools request failed
  [1.087][DEBUG]: DevTools request: http://127.0.0.1:12710/json/version
  [1.087][DEBUG]: DevTools request failed
  [1.138][DEBUG]: DevTools request: http://127.0.0.1:12710/json/version
  ................................................................
  ................................................................
  [61.031][INFO]: RESPONSE InitSession unknown error: Chrome failed to start: exited abnormally
  [61.031][DEBUG]: Log type 'driver' lost 0 entries on destruction
  [61.031][DEBUG]: Log type 'browser' lost 0 entries on destruction
  </code></pre>
  
  <p>I tried to run it from non root user as well, but still, I get same error.</p>
  
  <p>I can only SSH to this machine. I tried, if running the command in screen can help but no use, nor does using crontab.</p>
  
  <p>Any guidance will be very helpful.</p>
  
  <p>UPDATE 1:</p>
  
  <p>Below is the chromedriver log after reboot:</p>
  
  <pre><code>[1.003][INFO]: COMMAND InitSession {
     "capabilities": {
        "alwaysMatch": {
           "browserName": "chrome",
           "goog:chromeOptions": {
              "args": [ "start-maximized", "--disable-extensions", "--headless", "--disable-gpu", "--no-sandbox" ],
              "extensions": [  ]
           },
           "platformName": "any"
        },
        "firstMatch": [ {
  
        } ]
     },
     "desiredCapabilities": {
        "browserName": "chrome",
        "goog:chromeOptions": {
           "args": [ "start-maximized", "--disable-extensions", "--headless", "--disable-gpu", "--no-sandbox" ],
           "extensions": [  ]
        },
        "platform": "ANY",
        "version": ""
     }
  }
  [1.003][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_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.003][INFO]: Populating Local State file: {
     "background_mode": {
        "enabled": false
     },
     "ssl": {
        "rev_checking": {
           "enabled": false
        }
     }
  }
  [1.004][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --full-memory-crash-report --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.wpOJGk/internal --logging-level=1 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12725 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.XeSkzL data:,
  [1.004][DEBUG]: DevTools request: http://127.0.0.1:12725/json/version
  [1.008][WARNING]: PAC support disabled because there is no system implementation
  [1752:1752:0321/084842.042837:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
  [1.051][DEBUG]: DevTools request failed
  [1.102][DEBUG]: DevTools request: http://127.0.0.1:12725/json/version
  [1.102][DEBUG]: DevTools request failed
  [1.152][DEBUG]: DevTools request: http://127.0.0.1:12725/json/version
  [1.152][DEBUG]: DevTools request failed
  [1.203][DEBUG]: DevTools request: http://127.0.0.1:12725/json/version
  </code></pre>