I can't run geckodriver, python selenium ; [WinError 216]
Asked Answered
S

1

5

I've got the win32 drivers from

https://github.com/mozilla/geckodriver/releases

and placed the exe under the python38 folder

I'm running windows 11

OSError: [WinError 216] This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher

here you can find the full terminal output

https://pastebin.com/k3Gvm2nU

> `from selenium import webdriver
> from selenium.webdriver.common.keys import Keys
> from selenium.webdriver.common.by import By
> 
> driver = webdriver.Firefox()
> driver.get("http://www.python.org")
> assert "Python" in driver.title
> elem = driver.find_element(By.NAME, "q")
> elem.clear()
> elem.send_keys("l")
> elem.send_keys(Keys.RETURN)
> assert "No results found." not in driver.page_source`

this is the code, I was expecting it to open a firefox page but it doesn't, I think that geckodriver isn't running because its incompatible for some reasons?

Sardinia answered 14/11, 2022 at 17:37 Comment(1)
@John don;t click on that link: copy it and paste it to your browser's address bar. It's just a fairly new security measure taken by SoF. OP: try and reinstall your python setup, create a new virtual environment, make sure your geckodriver version matches your FF installed version, and you should be alright.Overliberal
S
6

You can use webdriver_manager to get rid of driver problems. You can use webdriver_manager for firefox as you can see in the link as follows

for selenium 3

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

for selenium 4

from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
Suck answered 14/11, 2022 at 19:51 Comment(1)
new Error : Message: Browsing context has been discardedFichtean

© 2022 - 2024 — McMap. All rights reserved.