How to solve Selenium webdriver. Firefox () cannot find the Geckodriver file
First declare: Python idle I can not find the settings to use environment variables, such as you have a better way, please leave a message, thank you.
Platform: MacOS software python comes with an idle version python3.6
Raw materials: First in the search engine self-search Geckodriver version of the latest download, unzip the file in the/usr/local/bin/
Following:
Error hint: selenium.common.exceptions.WebDriverException:Message: ' geckodriver ' executable needs to is in PATH.
Python IDLE has a lot of strange things, such as when unable to find the specified file, do not go to the system environment variables in the path to find, so with a lot of API library functions, they would have given the path of the initial value will be useless, to re- IDLE assign a value at the time of reference, or an exception will be thrown. Such as:
From selenium import Webdriverbrowser = Webdriver. Firefox ()
// has a default initial value for the parameter
That is, the geckodriver executable can be found in the system environment variable path in the echo $PATH in mac terminal ,pycharm can be done without changing the initial value to run normally,
However, python IDLE throws an exception, cannot find the geckodriver, must be re-assigned, with the executable program's absolute address to assign a value:
Browser = Webdriver. Firefox (executable_path= '/usr/local/bin/geckodriver ')
Can be executed normally, or you can directly find the webdriver.py in the selenium package to change the initial value of the above to the absolute address above, so that it is also possible to achieve Pythonidle can not be assigned to normal execution.
This article comes from the "Antidarkness's blog" blog, please be sure to keep this source http://antidarkness.blog.51cto.com/6146867/1974695
Fix Webdriver call Firefox () error (Mac Python3)