【发布时间】:2017-01-03 21:29:00
【问题描述】:
我在 Ubuntu 16.04 上安装了 python3-selenium apt 包。安装时,收到一条消息:
Suggested packages:
chromedriver firefoxdriver
The following NEW packages will be installed:
python3-selenium
当我尝试运行以下 python 代码时,
#! /usr/bin/python3.5
from selenium import webdriver
import time
def get_profile():
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.privatebrowsing.autostart", True)
return profile
def main():
browser = webdriver.Firefox(firefox_profile=getProfile())
#browser shall call the URL
browser.get("http://www.google.com")
time.sleep(5)
browser.quit()
if __name__ == "__main__":
main()
我收到以下错误:
Traceback(最近一次调用最后一次): 文件“./test.py”,第 19 行,在 主要的() 文件“./test.py”,第 11 行,在 main 浏览器 = webdriver.Firefox(firefox_profile=getProfile()) init 中的文件“/usr/lib/python3/dist-packages/selenium/webdriver/firefox /webdriver.py”,第 77 行 self.binary,超时), init 中的文件“/usr/lib/python3/dist-packages/selenium/webdriver/firefox/extension_connection.py”,第 47 行 self.profile.add_extension() 文件“/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py”,第 91 行,在 add_extension self._install_extension(扩展) _install_extension 中的文件“/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py”,第 251 行 压缩文件 = zipfile.ZipFile(插件, 'r') init 中的文件“/usr/lib/python3.5/zipfile.py”,第 1009 行 self.fp = io.open(文件,文件模式) FileNotFoundError: [Errno 2] 没有这样的文件或目录:'/usr/lib /firefoxdriver/webdriver.xpi'
我确实在 Ubuntu 存储库中搜索了名为 firefoxdriver 的软件包,但不存在。 我该如何解决这个问题?
任何有关安装网络驱动程序的帮助表示赞赏!
【问题讨论】:
-
请尝试在 $nano ~.bashrc 中导出 geckdriver 的路径,这会将驱动程序路径分配给 Profile。
标签: python python-3.x selenium selenium-webdriver python-3.5