2016-11-11 95 views
1

報價:「chromedriver」可執行文件需要在PATH硒 - chromedriver可執行文件需要在PATH從錯誤味精

我試圖代碼pycharm使用硒的腳本。但後來我得到了上述錯誤。我已經將我的硒鏈接到pycharm,如下所示:https://gyazo.com/b5622e3165bbfd93cfa205178df79b6f - (最新和最新)

我是硒的新手,isnt chromedriver在「硒」文件夾中。 如果不能找到它並將其添加到路徑中?

順便說一句,嘗試在CMD中鍵入「chromedriver」,它不被視爲內部或外部命令。如下圖所示

錯誤:

Traceback (most recent call last): 
    File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start 
    stdout=self.log_file, stderr=self.log_file) 
    File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__ 
    restore_signals, start_new_session) 
    File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child 
    startupinfo) 
PermissionError: [WinError 5] Adgang nægtet 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:/Users/sebastian/PycharmProjects/web/bot.py", line 10, in <module> 
    browser = webdriver.Chrome("C:/Users/sebastian/desktop/selenium-3.0.1") 
    File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__ 
    self.service.start() 
    File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start 
    os.path.basename(self.path), self.start_error_message) 
selenium.common.exceptions.WebDriverException: Message: 'selenium-3.0.1' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home 

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x01EDEAF0>> 
Traceback (most recent call last): 
    File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__ 
    self.stop() 
    File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop 
    if self.process is None: 
AttributeError: 'Service' object has no attribute 'process' 

回答

8

你可以在這裏下載ChromeDriver: https://sites.google.com/a/chromium.org/chromedriver/downloads

那麼它要麼添加到您的path,或把它放在同一目錄下的Python腳本或指定位置直接,例如

driver = webdriver.Chrome('C:/path/to/chromedriver.exe') 
+1

每個瀏覽器都需要自己的驅動程序,Linux上沒有IE或Windows上沒有Safari。硒只是一個工具,可以讓你「聊天」到瀏覽器。 –

+0

在將路由器添加到路由器後引發了一個新錯誤。 你能發現問題是什麼嗎? 它的一些事情,「權限被拒絕」。我如何給予它許可? –

+1

你給完整路徑的exe或路徑?你需要exe文件的位置。如果問題仍然存在,請在此處搜索錯誤消息,我確定有人遇到過相同的問題。 –

3

另一種方法是下載和uzip chromedriver並把 'chromedriver.exe' 在C:\ Python27 \ Scripts中,然後你不需要提供驅動程序的路徑,只是

driver= webdriver.Chrome() 

將工作

相關問題