欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python3+selenium配置常見報(bào)錯(cuò)解決方案

 更新時(shí)間:2020年08月28日 10:39:12   作者:羅維翩  
這篇文章主要介紹了Python3+selenium配置常見報(bào)錯(cuò)解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

第一個(gè)坑:'geckodriver' executable needs to be in PATH

1.如果啟動(dòng)瀏覽器過程中報(bào)如下錯(cuò)誤

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 145, in __init__
self.service.start()
File "D:\test\python3\lib\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.

2.這個(gè)是因?yàn)樽钚碌膕elenium3.0啟動(dòng)firefox需要geckodriver.exe這個(gè)驅(qū)動(dòng)文件。

3.下載之后,配置到環(huán)境變量path下(可以直接放python根目錄)

第二坑:Expected browser binary location, but unable to find binary in default location

1.如果啟動(dòng)瀏覽器過程中報(bào)如下錯(cuò)誤:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 155, in __init__
keep_alive=True)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)

File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Expected browser binary location, but unable to find binary in default location,
no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line.

2.這個(gè)是因?yàn)閒irefox.exe這個(gè)文件也需要配置到環(huán)境變量path下。

3.這個(gè)路徑就是安裝完firefox后,找到firefox.exe這個(gè)文件的地址,加到path下。

第三坑:Unsupported Marionette protocol version 2, required 3

1.如果啟動(dòng)瀏覽器過程中出現(xiàn)如下錯(cuò)誤

Traceback (most recent call last):
File "<stdin>", line 1, in <module>

File "D:\test\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 155, in __init__
keep_alive=True)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "D:\test\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Unsupported Marionette protocol version 2, required 3

2.這個(gè)錯(cuò)誤原因是firefox版本過低了,最新的selenium3.0版本支持firefox47以上的版本,升級(jí)版本就可以了

第四坑:WebDriverException: Message: newSession

1.Traceback (most recent call last):

File “D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”, line 170, in init
keep_alive=True)
File “D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”, line 156, in init
self.start_session(capabilities, browser_profile)
File “D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”, line 245, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File “D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\webdriver.py”, line 314, in execute
self.error_handler.check_response(response)
File “D:\test\python3\lib\site-packages\selenium\webdriver\firefox\\errorhandler.py”, line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: newSession

2.下載最新的geckodriver.exe 然后把它放到python的安裝目錄下

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 在ironpython中利用裝飾器執(zhí)行SQL操作的例子

    在ironpython中利用裝飾器執(zhí)行SQL操作的例子

    這篇文章主要介紹了在ironpython中利用裝飾器執(zhí)行SQL操作的例子,文章中以操作MySQL為例,需要的朋友可以參考下
    2015-05-05
  • Python中查找素因數(shù)的方法詳解

    Python中查找素因數(shù)的方法詳解

    這篇文章主要為大家詳細(xì)介紹了如何在 Python 中執(zhí)行素因數(shù)分解,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴可以一起學(xué)習(xí)一下
    2023-10-10
  • DataFrame窗口函數(shù)rolling()的用法

    DataFrame窗口函數(shù)rolling()的用法

    這篇文章主要介紹了DataFrame窗口函數(shù)rolling()的用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • Python3利用openpyxl讀寫Excel文件的方法實(shí)例

    Python3利用openpyxl讀寫Excel文件的方法實(shí)例

    這篇文章主要給大家介紹了關(guān)于Python3利用openpyxl讀寫Excel文件的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • python聊天室(雖然很簡潔,但是可以用)

    python聊天室(雖然很簡潔,但是可以用)

    這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)多人聊天室,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • Python通過Tesseract庫實(shí)現(xiàn)文字識(shí)別

    Python通過Tesseract庫實(shí)現(xiàn)文字識(shí)別

    這篇文章主要介紹了Python通過Tesseract庫實(shí)現(xiàn)文字識(shí)別,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-03-03
  • Python實(shí)現(xiàn)批量繪制遙感影像數(shù)據(jù)的直方圖

    Python實(shí)現(xiàn)批量繪制遙感影像數(shù)據(jù)的直方圖

    這篇文章主要為大家詳細(xì)介紹了如何基于Python中g(shù)dal模塊,實(shí)現(xiàn)對(duì)大量柵格圖像批量繪制直方圖,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
    2023-02-02
  • matplotlib交互式數(shù)據(jù)光標(biāo)實(shí)現(xiàn)(mplcursors)

    matplotlib交互式數(shù)據(jù)光標(biāo)實(shí)現(xiàn)(mplcursors)

    這篇文章主要介紹了matplotlib交互式數(shù)據(jù)光標(biāo)實(shí)現(xiàn)(mplcursors),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 使用LibTorch進(jìn)行C++調(diào)用pytorch模型方式

    使用LibTorch進(jìn)行C++調(diào)用pytorch模型方式

    這篇文章主要介紹了使用LibTorch進(jìn)行C++調(diào)用pytorch模型方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • python編程使用selenium模擬登陸淘寶實(shí)例代碼

    python編程使用selenium模擬登陸淘寶實(shí)例代碼

    這篇文章主要介紹了python編程使用selenium模擬登陸淘寶實(shí)例代碼,涉及selenium的簡介及Windows下的安裝,分享了相關(guān)代碼示例,小編覺得還是挺不錯(cuò)的,具有一定借鑒價(jià)值,需要的朋友可以參考下
    2018-01-01

最新評(píng)論