2017-10-30 1 views
0

Firefox 용 Selenium Geckodriver를 당분간 Mac에서 사용할 수 없게되었습니다.Selenium Geckodriver가 Python에서 작동하지 못함 - Mac OSX High Sierra

설명서에 표시된대로 geckodriver 바이너리가/usr/local/bin/디렉토리에 있습니다.

때 나는 다음과 같은 실행하려고 적 :

from selenium import webdriver 
browser = webdriver.Firefox() 
type(browser) 
browser.get('www.google.com')enter code here 

내가 파이썬 콘솔에서 다음과 같은 오류가 발생합니다.

Traceback (most recent call last): 
    File "/Users/maxmorin/.thonny/BundledPython36/lib/python3.6/site- 
packages/selenium/webdriver/common/service.py", line 74, in start 
stdout=self.log_file, stderr=self.log_file) 
    File "/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__ 
restore_signals, start_new_session) 
    File "/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child 
raise child_exception_type(errno_num, err_msg) 
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/Users/maxmorin/Google Drive/Support Team Python Code/Max's Projects/Release Readiness/selenium_test.py", line 2, in <module> 
browser = webdriver.Firefox() 
    File "/Users/maxmorin/.thonny/BundledPython36/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__ 
self.service.start() 
    File "/Users/maxmorin/.thonny/BundledPython36/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 81, in start 
os.path.basename(self.path), self.start_error_message) 
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

답변

0

경로를 geckodriver로 설정해야합니다.

  • chmod를 + X geckodriver ++

편집

것은 원하지 않는 경우

driver = webdriver.Firefox(profile, executable_path=r'/pathTo/geckodriver') 
driver.get("https://www.google.com") 

하면 파일이 실행되어 있는지 확인하십시오 방법은 다음과 같다 코드에서 executable_path를 지정하려면 PATH 환경 변수에 다음을 추가해야합니다.

export PATH=$PATH:/path/to/geckodriver 
+0

감사합니다. 매번 실행 경로에 넣지 않아도되도록 PATH 위치에 쉽게 구성 할 수 있습니까? –

+0

@MaxMorin 방금 답변을 수정했습니다. –

관련 문제