SeleniumHQ/selenium · critical · WebDriverException
Service path cannot be None.
Error message
Service path cannot be None.
What it means
Raised by Service.start() at the very first line if self._path is None. The _path is computed in __init__ as 'env_path() or executable_path', so it is None only when no driver_path_env_key env var is set AND no executable_path was passed to the constructor. This guard fires before any process is launched.
Source
Thrown at py/selenium/webdriver/common/service.py:107
raise NotImplementedError("This method needs to be implemented in a sub class")
@property
def path(self) -> str:
return self._path or ""
@path.setter
def path(self, value: str) -> None:
self._path = str(value)
def start(self) -> None:
"""Starts the Service.
Raises:
WebDriverException: Raised either when it can't start the service
or when it can't connect to the service
"""
if self._path is None:
raise WebDriverException("Service path cannot be None.")
self._start_process(self._path)
count = 0
try:
while True:
self.assert_process_still_running()
if self.is_connectable():
break
# sleep increasing: 0.01, 0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36, 0.41, 0.46, 0.5
sleep(min(0.01 + 0.05 * count, 0.5))
count += 1
if count == 70:
raise WebDriverException(f"Can not connect to the Service {self._path}")
except BaseException:
try:
self.stop()
except Exception:
logger.error("Error stopping service after a failed start.", exc_info=True)View on GitHub (pinned to aa36b38e69)
Solutions
- Pass an explicit driver path: Service(executable_path='/path/to/chromedriver').
- Set the driver env var for your browser, e.g. export SE_GECKODRIVER=/usr/bin/geckodriver.
- Let Selenium Manager resolve the driver automatically by upgrading selenium and not overriding executable_path.
- Verify the variable you pass to executable_path is not None before constructing the Service.
Example fix
# before service = Service(executable_path=None) # or just Service() service.start() # -> Service path cannot be None. # after from selenium.webdriver.chrome.service import Service service = Service(executable_path='/usr/local/bin/chromedriver')
Defensive patterns
Strategy: validation
Validate before calling
from selenium.webdriver.chrome.service import Service
path = os.getenv('SE_CHROMEDRIVER') or '/usr/local/bin/chromedriver'
assert path and Path(path).is_file(), 'No driver path; set SE_CHROMEDRIVER or pass executable_path'
service = Service(executable_path=path) Type guard
def is_valid_driver_path(p) -> bool:
return isinstance(p, str) and p and Path(p).is_file() Try / catch
from selenium.common.exceptions import WebDriverException
try:
service.start()
except WebDriverException as e:
if 'Service path cannot be None' in str(e):
service.path = '/usr/local/bin/chromedriver'
service.start() Prevention
- Always pass an explicit executable_path in environments without Selenium Manager.
- Set the browser-specific driver env var (SE_CHROMEDRIVER etc.) in CI.
- Validate the path variable is not None before constructing the Service.
When it happens
Trigger: Constructing a browser-specific Service with executable_path=None (the default) while the corresponding driver env var (e.g. SE_CHROMEDRIVER, SE_GECKODRIVER, SE_EDGEDRIVER) is unset, and then calling .start(). This typically happens only when Selenium Manager is also unavailable to supply the path automatically.
Common situations: Disabling Selenium Manager or using a very old selenium version, explicitly passing executable_path=None, or a misconfigured CI where the expected env var is empty rather than absent. Also seen when someone passes executable_path as a variable that evaluated to None.
Related errors
- Can not connect to the Service {self._path}
- Service {self._path} unexpectedly exited. Status code was: {
- service_args must be a sequence
- invalid port: #{@port}
- Unable to obtain browser driver. For more informatio
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/687e78de5ab659f2.
Report an issue: GitHub.