2016-11-11 113 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() 

将工作

相关问题