Reputation:
I have freshly installed Chrome on my pc. I have installed Anaconda. I have tried putting Chrome in the Anaconda directory wtih Chrome.
I've got a clean Anaconda, I've installed chromedriver through Anaconda, as well as downloaded it and tried it through Cmd. I also have tried just about every relevant folder I can think of but it just can't seem to find path. I've deleted every visible Chromedriver in case it's getting that.
Any idea on how to fix this issue as I've spent the better half of 4 hours attempting to get Python to stop creating issues.
The last time I did this was 4 months ago and I remember a similar headache.
Is there a set directory I am overlooking where chromedriver must go or you shall suffer the fate of
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
for all eternity
Upvotes: 2
Views: 4302
Reputation: 8558
The simplest solution is to install chromedriver like this:
conda install -c conda-forge python-chromedriver-binary
Then at the top of your code, add the following import statement to update your PATH variable appropriately:
import chromedriver_binary
Upvotes: 1
Reputation: 752
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
The message states that the directory containing chromedriver.exe needs to be in path, that means that it can´t find the executable in any of the directories in the PATH variable, you can add the directory containing the .exe to the path variable with the OS settings:
The other option is to set up a environment before running python from CMD:
path = %PATH%;C:/dir/to/your/chromedriverdir
python
What this does is sets the variable named path to the value of the previous variable %PATH% and adds another dir to the end. This is only set locally in the sesion of your cmd window, if you close it, it goes away.
This method and the method a2mky sugested are the preferred methods over the system settings.
Personally I use driver = webdriver.Chrome(executable_path=r"C:\Chrome\chromedriver.exe")
I wanted to add this answer to clarify the error message and the next time you see it, makes sense to you.
Your best friend in case of errors, are the error messages.
Upvotes: 5
Reputation: 193
You need to specify the path of the executable.
driver = webdriver.Chrome(executable_path=r"C:\Chrome\chromedriver.exe")
Upvotes: 5