Python selenium driver chrome - WebDriverException: Message: 'chromedriver' executable needs to be in PATH

how to work with selenium in python on nixos?

from selenium import webdriver
driver = webdriver.Chrome()

results in

WebDriverException                        Traceback (most recent call last)
<ipython-input-3-04897e3af1b8> in <module>
      1 from Screenshot import Screenshot_Clipping
      2 from selenium import webdriver
----> 3 driver = webdriver.Chrome()

/nix/store/59hsifg8fpp52729wkqvi19wzz83n3k1-python3-3.7.9-env/lib/python3.7/site-packages/selenium/webdriver/chrome/ in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
     71             service_args=service_args,
     72             log_path=service_log_path)
---> 73         self.service.start()
     75         try:

/nix/store/59hsifg8fpp52729wkqvi19wzz83n3k1-python3-3.7.9-env/lib/python3.7/site-packages/selenium/webdriver/common/ in start(self)
     81                 raise WebDriverException(
     82                     "'%s' executable needs to be in PATH. %s" % (
---> 83                         os.path.basename(self.path), self.start_error_message)
     84                 )
     85             elif err.errno == errno.EACCES:

WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see

We have a chromedriver package in Nixpkgs, which you can add to a package or project shell using the nativeBuildInputs argument.

# mkShell {
# or
# stdenv.mkDerivation {

  nativeBuildInputs = [ chromedriver ];

This will put chromedriver in PATH, as suggested by the error message.

If you’re not packaging anything and your project doesn’t have a Nix shell, and you just want to run the thing, you could add it to NixOS.

  environment.systemPackages = [ pkgs.chromedriver ];

or install it imperatively, as suggested on NixOS Search - Loading...

Thanks for your answer
I think in my case the version(s) didn’t fit together …

1 Like