第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用Python的Selenium-Geckoriver可執(zhí)行文件需要在路徑中。

使用Python的Selenium-Geckoriver可執(zhí)行文件需要在路徑中。

使用Python的Selenium-Geckoriver可執(zhí)行文件需要在路徑中。我對編程很陌生,一開始Python大約兩個月前,我正在檢查斯威加特的用Python自動化無聊的東西短信。我使用的是空閑,并且已經(jīng)安裝了Selenium模塊和Firefox瀏覽器。每當(dāng)我嘗試運(yùn)行Webriver函數(shù)時,我都會得到以下內(nèi)容:from selenium import webdriver browser = webdriver.Firefox()例外:-Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0DA1080>>Traceback  (most recent call last):   File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__     self.stop()   File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop       if self.process is None:AttributeError: 'Service' object has no attribute 'process'Exception ignored in: <bound method Service.__del__    of <selenium.webdriver.firefox.service.Service object at 0x00000249C0E08128>>Traceback (most recent call last):   File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__     self.stop()   File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop       if self.process is None:AttributeError: 'Service' object has no attribute 'process'Traceback (most recent call last):   File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start     stdout=self.log_file, stderr=self.log_file)   File "C:\Python\Python35\lib\subprocess.py", line 947, in __init__     restore_signals, start_new_session)   File "C:\Python\Python35\lib\subprocess.py", line 1224, in _execute_child     startupinfo)FileNotFoundError: [WinError 2] The system cannot find the file specifiedDuring handling of the above exception,      another exception occurred:Traceback (most recent call last):   File "<pyshell#11>", line 1, in <module>     browser = webdriver.Firefox()我想我需要為geckodriver但不知道怎么做,所以有人能告訴我怎么做嗎?
查看完整描述

3 回答

?
梵蒂岡之花

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個贊

selenium.common.exceptions.WebDriverException:消息:“geckoriver”可執(zhí)行文件需要在路徑中。

首先,您需要從這里下載最新的可執(zhí)行g(shù)eckoriver,以便使用Selenium運(yùn)行最新的Firefox。

實(shí)際上,Selenium客戶端綁定試圖定位geckodriver來自系統(tǒng)的可執(zhí)行文件PATH..您需要將包含可執(zhí)行文件的目錄添加到系統(tǒng)路徑。

  • 在Unix系統(tǒng)上,如果使用的是bash兼容的shell,則可以執(zhí)行以下操作將其附加到系統(tǒng)的搜索路徑:

    export PATH=$PATH:/path/to/directory/of/executable/downloaded/in/previous/step
  • 在Windows上,您需要更新路徑系統(tǒng)變量,以將完整目錄路徑添加到可執(zhí)行的geckoriver中。 手動命令行(不要忘記在系統(tǒng)路徑中添加可執(zhí)行的geckoriver后重新啟動系統(tǒng)才能生效)..原理與Unix相同。

現(xiàn)在您可以運(yùn)行代碼,如下所示:-

from selenium import webdriver

browser = webdriver.Firefox()

selenium.common.exceptions.WebDriverException:消息:預(yù)期的瀏覽器二進(jìn)制位置,但無法在默認(rèn)位置找到二進(jìn)制,沒有提供‘moz:FirefoxOptions.二進(jìn)制’功能,命令行上沒有設(shè)置二進(jìn)制標(biāo)志

異常很清楚地表明,您已經(jīng)安裝了Firefox的其他位置,而Selenium試圖找到Firefox并從默認(rèn)位置啟動,但是它找不到。您需要顯式地提供Firefox安裝的二進(jìn)制位置,以啟動Firefox,如下所示:

from selenium import webdriverfrom selenium.webdriver.firefox.firefox_binary import FirefoxBinarybinary = 
FirefoxBinary('path/to/installed firefox binary')browser = webdriver.Firefox(firefox_binary=binary)


查看完整回答
反對 回復(fù) 2019-06-06
  • 3 回答
  • 0 關(guān)注
  • 1108 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號