일부 웹 사이트에서 데이터를 가져 오기 위해 Selenium을 사용하는 Python 프로그램을 작성했습니다. 내가 py2exe에를 사용하여 실행 파일이 변환 한 동료와 공유하려면 지금 일부 입력 인수 (2) 파이어 폭스 바이너리 & (3) 도마뱀 드라이버Python 코드는 작동하지만 py2exe를 사용하여 실행 가능하지 않습니다.
를 (1) 텍스트 파일이 내 코드는 3 개의 파일이 필요하다는 것을 의미한다.
쉘에서 실행될 때의 프로그램은 전혀 작동하지 않습니다. 그러나 실행 파일을 통해 동일하게 실행될 때 여러 가지 오류가 발생합니다. - (1) 입력 인수 파일을 찾을 수 없습니다. (2) gecko 드라이버를 찾을 수 없습니다. (3) Windows에서 오류 6을 처리합니다.) 어떻게 그것이 실행 가능하게 작동하는지 확인합니까? 코드에서
발췌 :
gdir = str(os.path.realpath('.'))
gdir = gdir.replace('\\','\\\\')
inpArgPath = gdir + '\\\\inputArguments.txt'
ffpath = 'FirefoxPortable/App/Firefox64/firefox.exe'
binary = webdriver.firefox.firefox_binary.FirefoxBinary(ffpath)
gecko = gdir + '\\\\gecko\\\\geckodriver64.exe'
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.forbid_open_with",True)
fp.set_preference("browser.download.altClickSave",True)
fp.set_preference("browser.download.manager.showWhenStarting",False)
browser = webdriver.Firefox(firefox_binary=binary, firefox_profile=fp, executable_path=gecko)
셀레늄 오류 : 오류의
Traceback (most recent call last):
File "weeklyData_v5.py", line 18, in <module>
IOError: [Errno 2] No such file or directory: 'inputArguments.txt'
Traceback (most recent call last):
File "weeklyData_v5.py", line 18, in <module>
IOError: [Errno 2] No such file or directory: 'inputArguments.txt'
두 더 많은 예제 :
File "selenium\webdriver\firefox\webdriver.pyc", line 144, in __init__
File "selenium\webdriver\common\service.pyc", line 81, in start
selenium.common.exceptions.WebDriverException: Message: 'geckodriver32.exe' executable needs to be in PATH.
-
browser = webdriver.Firefox(firefox_binary=binary, firefox_profile=fp, executable_path=gecko)
File "selenium\webdriver\firefox\webdriver.pyc", line 144, in __init__
File "selenium\webdriver\common\service.pyc", line 74, in start
File "subprocess.pyc", line 382, in __init__
File "subprocess.pyc", line 515, in _get_handles
File "subprocess.pyc", line 566, in _make_inheritable
WindowsError: [Error 6] The handle is invalid
감사합니다. 이 변경을했는데 코드는 여전히 작동합니다. 그러나 실행 파일 (py2exe)을 실행하면 "NameError : name '__ file __'이 정의되지 않았습니다."라는 오류가 발생합니다. – dsauce
@dsauce는 업데이트 된 대답을보고 py2exe를 전문으로합니다. – deets
감사합니다. 이로 인해 가끔 exe 코드가 작동하지만 가끔씩 오류가 발생합니다 (예 : gecko 드라이버를 찾을 수 없음) 또는 "WindowsError : [오류 6] 핸들이 유효하지 않습니다". 더 많은 오류 예제로 질문 텍스트를 업데이트했습니다. – dsauce