找不到webdriver.xpi - Python3,Linux Mint

时间:2018-01-28 16:42:40

标签: linux python-3.x selenium webdriver

我是论坛的新手但是已经在帖子中查找了解决问题的方法。

以下是我用于尝试排查的帖子: #1 #2 〜和其他谷歌的结果。

我从Windows切换到Linux Mint,但我无法设置。我也是Python /编程的新手,所以请耐心等待。

Linux Mint安装了Python2但是我已经完成了Python3的所有练习,所以我安装了Python 3,这意味着我还必须安装Selenium,Geckodriver等的Python3版本才能运行我的练习脚本用于webscraping。

当我运行我的代码时,它会按照我的意图提示搜索字词,但之后会抛出以下错误:

Traceback (most recent call last):
  File "/home/myName/Documents/Programming Misc/Python/craigslistSearch_linkGeneration_v02.py", line 15, in <module>
    browser = webdriver.Firefox()
  File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/webdriver.py", line 77, in __init__
    self.binary, timeout),
  File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.profile.add_extension()
  File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 91, in add_extension
    self._install_extension(extension)
  File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 251, in _install_extension
    compressed_file = zipfile.ZipFile(addon, 'r')
  File "/usr/lib/python3.5/zipfile.py", line 1009, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/firefoxdriver/webdriver.xpi'

以下是有问题的代码:

from selenium import webdriver  #To launch the browser (Firefox)
from selenium.webdriver.common.keys import Keys #To be able to send special keys (i.e., DOWN, UP, RIGHT, LEFT, TAB, HOME, etc.)
import time #To pause the program for x seconds
import string #To run string.replace()
import requests

#prompt the user to enter their desired search term
print('Please enter your search term')
searchTerm = input()
newSearchTerm = str.replace(searchTerm, ' ', '+')



#open browser and navigate to craigslist + user-defined search term(s)
browser = webdriver.Firefox()
type(browser)
searchURL = browser.get('https://seattle.craigslist.org/search/sss?query=' + newSearchTerm)

1 个答案:

答案 0 :(得分:0)

我怀疑你为Python 3安装了旧的Selenium,因为webdriver.xpi是firefox浏览器的遗留webdriver,它被geckodriver取代。

请显示您安装的Selenium,geckodriver和其他相关内容的版本。

如果您使用Selenium 2,它将尝试查找webdriver.xpi,因为Selenium 3,它会尝试查找geckodriver,因此请尝试安装Selenium 3或更高版本。