Dear Maintainer,
The current selenium package fails to create either webdriver.Firefox() or webdriver.Chrome(). I have firefox, chromium, and geckodriver (downloaded from mozilla.org github) all in my path.
The error is a KeyError: 'CONDA_PREFIX' because it's trying to access os.environ["CONDA_PREFIX"]. I don't have CONDA_PREFIX set because I don't use conda. I tried setting it to '' but I just got a slightly different error. I've tried setting the path to the firefox executable even though it's in my path, but it didn't help.
selenium via pip install selenium works fine, at least for webdriver.Firefox() (webdriver.Chrome() eventually works but takes several minutes to pop up a window, I haven't looked into why) and doesn't give any errors regarding conda.
Here's the full error message and how to reproduce it:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py", line 38, in get_path
path = SeleniumManager().driver_location(options) if path is None else path
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py", line 81, in driver_location
args = [str(self.get_binary()), "--browser", browser]
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/selenium/webdriver/common/selenium_manager.py", line 60, in get_binary
if not path.is_file() and os.environ["CONDA_PREFIX"]:
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "<frozen os>", line 679, in __getitem__
KeyError: 'CONDA_PREFIX'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
self.service.path = DriverFinder.get_path(self.service, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/selenium/webdriver/common/driver_finder.py", line 41, in get_path
raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for firefox using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location