Cannot get GeckoDriver 0.8 to work with Python + Selenium
Re https://github.com/seleniumhq/selenium/issues/2110. I followed instructions at WebDriver - Mozilla | MDN. My setup:
OS X 10.9.5Python 3.5.1:: Continuum Analytics, Inc.- Python module
selenium==2.53.5 Firefox 47.0- 'GeckoDriver 0.8.0`
I downloaded GeckoDriver to `'/Users/raymondyee/bin/geckodriver'. When I run:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Users/raymondyee/bin/geckodriver'
driver = webdriver.Firefox(capabilities=firefox_capabilities)
I eventually get a timeout:
Traceback (most recent call last):
File "ff_se_test.py", line 8, in <module>
driver = webdriver.Firefox(capabilities=firefox_capabilities)
File "/Users/raymondyee/anaconda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 74, in __init__
keep_alive=True)
File "/Users/raymondyee/anaconda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Users/raymondyee/anaconda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/Users/raymondyee/anaconda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Users/raymondyee/anaconda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused
Interestingly, the geckodriver.log reports:
Usage:
/Users/raymondyee/bin/geckodriver [OPTIONS]
/Users/raymondyee/bin/geckodriver: Unknown option --marionette
I might try downgrading to Firefox 46 but I understand that eventually Marionette is required once we go to FF 48.0
firefox_capabilities['binary'] points to the firefox binary itself, not geckodriver.
Instead, add the directory where geckodriver lives to your path:
os.environ["PATH"] += ":/Users/raymondyee/bin/geckodriver"
I found that the python bindings (2.53.2) are still looking for the "wires" executable so I created a symlink from wires -> geckodriver
Hope this helps.
I would like there to be a mechanism that didn't require the driver it to be in the path, as this is not necessary for ChromeDriver or IEDriverServer.exe as you can pass their path as an argument when starting the driver.
Thanks @dbl82 for helping me figure out that firefox_capabilities['binary'] should point to Firefox itself and not to the geckodriver. I misread the documentation but am glad to see that the Python example has been since updated.
I made the change to firefox_capabilities['binary'], and my code now works.
@rdhyee @dbl82
I updated the instructions on how to use Marionette to reflect that capabilities["binary"] should be the full path to the browser binary.
Thanks for keeping the feedback coming! :+1:
Hi,
I went through the steps to resolve this issue and I am still getting the same error. I had set a path in my .bash_profile to geckodriver and made sure my script was pointing to the firefox bin. The path I set in .bash_profile is
export PATH=PATH$:~/
Any help would be much appreciated!
export PATH=PATH$:~/
This will unexport all your other paths. You should read up on the system path, but I suspect you want something akin to:
export PATH=$PATH:/path/to/containing/folder
Then you put the geckodriver binary inside /path/to/containing/folder.
Ah, sorry my path was unclear, originally I was using: export PATH=$PATH:~/selenium/geckodriver
I just updated it to the full path:
export PATH=$PATH:/Users/
I am still getting the same error mentioned in the original issue so I am still unsure what else I am missing.
You… haven’t actually said which error you’re getting.
opps...sorry. The traceback I'm getting is
Traceback (most recent call last):
File "/Users/username/PycharmProjects/stuff/FirefoxTest.py", line 19, in
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.del of <selenium.webdriver.firefox.service.Service object at 0x10bda6f90>> ignored
Hope that helps further.
Well you appear to have two problems: The Selenium Python binding you’re using appears to look for wires (not geckodriver), and there’s a programming error where some internal code in that binding is trying to access a process attribute on the Service object.
I would suggest using a more recent version, or preferably, installing it from source.
I had just tried 0.9 and 0.10 with the same traceback errors. How would I go about installing from source. I am still new at this and I do apologize for being annoying but your help is greatly appreciated!
As I said in my previous comment, this is a Selenium issue and not a geckodriver issue.
Ah. ok. I'll take a look into that. Thanks again for the advice!
Hi, I am using python 3.5 on Windows 10, and I have a Firefox v49 installed. I have the following items in the PATH variable, in this order: C:\Users\csorn\tools\Firefox C:\Users\csorn\tools\gecko
My sys.path contains these 2 in the fist place: 'C:\Users\csorn\tools\Firefox', 'C:\Users\csorn\tools\gecko'
My gecko folder above contains only wires.exe.
I am still getting WebDriverException: 'geckodriver' executable needs to be in PATH.
(More precisely: Traceback (most recent call last): File "C:\Users\csorn\Anaconda3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 68, in init self.service.start() File "C:\Users\csorn\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. )
My code is as simple as below: from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities firefox_capabilities = DesiredCapabilities.FIREFOX firefox_capabilities['marionette'] = True firefox_capabilities['binary'] = 'C:\Users\csorn\tools\Firefox' driver = webdriver.Firefox(capabilities=firefox_capabilities)
Does anybody have any idea, why I am getting this error?
@csornaigyula You likely need to upgrade Selenium. geckodriver used to be called “wires”, but it is now called “geckodriver”. It is looking for wires.exe, whereas more recent Selenium versions look for geckodriver.exe.
Hi Andreas, 1- thanks for the response, and terribly sorry for checking back late. 2- it is most possibly not about version, because as I mentioned I renamed the driver to be wires based on other recommendation, that is a new driver.
Anyway, I will try further.
I have issue, kindly helpout me
harshmaur@harshmaur:~/Desktop/scrapynew$ scrapy crawl sh
/home/harshmaur/Desktop/scrapynew/scrapynew/spiders/babyoye.py:3: ScrapyDeprecationWarning: Module scrapy.contrib.spiders is deprecated, use scrapy.spiders instead
from scrapy.contrib.spiders import CrawlSpider, Rule
/home/harshmaur/Desktop/scrapynew/scrapynew/spiders/babyoye.py:4: ScrapyDeprecationWarning: Module scrapy.contrib.linkextractors is deprecated, use scrapy.linkextractors instead
from scrapy.contrib.linkextractors import LinkExtractor
/home/harshmaur/Desktop/scrapynew/scrapynew/spiders/shopclues_spider.py:3: ScrapyDeprecationWarning: Module scrapy.contrib.linkextractors.sgml is deprecated, use scrapy.linkextractors.sgml instead
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 11, in
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.del of <selenium.webdriver.firefox.service.Service object at 0x7f92dc9b3c10>> ignored
I’m locking this conversation as the issue as been resolved and none of the follow-up comments that have been posted have had anything actionable in them.