【发布时间】:2016-10-16 17:58:18
【问题描述】:
在 Ubuntu 中安装 Selenium 并将 geckodriver 添加到路径后,运行时出现此错误
from selenium import webdriver
driver = webdriver.Firefox()
错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 20] Not a directory
发生了什么事?
编辑:使用 chromedriver 而不是 geckodriver 解决。
【问题讨论】:
-
您是否尝试过在您的
driver = webdriver.Firefox()行中提供geckodriver 的路径?它可能只是找不到驱动程序。 -
@THeeren 你的意思是像 driver = webdriver.Firefox("/home/User/Downloads/wires") 吗?我试过并得到这个错误`Traceback(最近一次调用最后):文件“
”,firefox_profile = FirefoxProfile(firefox_profile)文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox /firefox_profile.py”,第 78 行,在 init ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock")) 文件 "/usr/lib/python2.7 /shutil.py",第 171 行,在 copytree names = os.listdir(src) OSError: [Errno 20] Not a directory: '/home/User/Downloads/wires'` -
您至少需要提供包括驱动程序名称在内的完整路径。我用的是chromedriver。对于 Firefox 驱动程序,您可能需要先创建配置文件。
-
我遇到了同样的错误。我尝试使用 chromedriver 和 geckodriver。我正在使用 ubuntu 16.10。