0

I am new to the forum but have searched the posts for something to fix my problem.

Here are the posts I've used to attempt troubleshooting: #1 #2 ~And other Google results.

I switched to Linux Mint from Windows and I am having trouble getting set up. I am also new to Python/programming in general, so bear with me.

Linux Mint comes with Python2 installed but I have done all of my practice with Python3, so I have installed Python 3 which means I also had to install the Python3 versions of Selenium, Geckodriver, etc. in order to run my practice scripts for webscraping.

When I run my code, it prompts for a search term as I intended, but then it throws the following error:

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'

Here's the offending code:

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)
Clueless
  • 13
  • 1

1 Answers1

0

I suspect you install old Selenium for Python 3, because webdriver.xpi is legacy webdriver for firefox browser, it's replaced by geckodriver.

Please show the version of Selenium, geckodriver and other related stuff you installed.

If you use Selenium 2, it will try to find webdriver.xpi, since Selenium 3, it will try to find geckodriver, so give a try to install Selenium 3 or heigher.

yong
  • 13,357
  • 1
  • 16
  • 27
  • Sorry I hit Enter but didn't finish typing Here's GeckoDriver ~ $ geckodriver --version geckodriver 0.11.1 I don't know why I can't find any of these things. I know for a fact that Selenium was working when I was using Python2 me@me-Linux ~ $ ActivePython --version ActivePython: command not found me@me-Linux ~ $ activepython --version activepython: command not found me@me-Linux ~ $ activepython -version activepython: command not found me@me-Linux ~ $ requests -version requests: command not found me@me-Linux ~ $ selenium --version selenium: command not found – Clueless Jan 29 '18 at 12:39
  • what version of Selenium for python you installed? – yong Jan 29 '18 at 12:41
  • i apologize - I will try to re-format my response above after work today so that it is easier to read. To answer your question, I am not sure what version of selenium I have. I know I have SOME version because it worked on Python 2.x — is it worth me uninstalling Python2 and its dependencies? Will that simplify things and cause fewer issues? – Clueless Jan 29 '18 at 13:38
  • SOLVED: I downloaded the "Python Wheel" version of Selenium and it seems to have worked. I had originally downloaded the Source tar ball. Here is where I went: (https://pypi.python.org/pypi/selenium#downloads) – Clueless Jan 29 '18 at 23:40