Fix Webdriver call Firefox () error (Mac Python3)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.