cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

webscraping with Firefox driver failing - Python code

375721
New Contributor II

Getting below exception while running web scraping script, stuck at installing firefox from snap.   Getting apparmor permission issue and tried to reinstall it and still getting the same. please check the error message section.

 

Dependencies:

Python library: selenium -> added to the cluster

 

Other dependencies:

Gecko driver installation:

 

%sh wget https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux-aarch64.t...

%sh tar -xvzf geckodriver-v0.33.0-linux-aarch64.tar.gz

%sh mv geckodriver /tmp

 

Firefox installation:

 

%sh /usr/bin/yes | sudo apt update --fix-missing

sudo apt-get --yes --force-yes install firefox

 

 

 

trying to run below sample code in notebook

 

from selenium import webdriver

from selenium.webdriver.firefox.options import Options

 

opts = Options()

opts.headless=True

browser = webdriver.Firefox(options=opts, executable_path='/tmp/geckodriver')

 

browser.get('https://mft.rrc.texas.gov/link/20ff2205-6579-450f-a2ee-cbd37986b557')

 

error message:
WebDriverException: Message: Process unexpectedly closed with status 1

 

 

 

 

I did some more research and found the below messages from geckodriver.log

 

Command '/usr/bin/firefox' requires the firefox snap to be installed. Please install it with: snap install firefox

 

And when I try to run  snap install firefox getting below error. 

error: system does not fully support snapd: AppArmor detected but insufficient permissions to use it

 

4 REPLIES 4

-werners-
Esteemed Contributor III

have you tried using apt instead of snap?

sudo apt install firefox

375721
New Contributor II

if you see my messages, I did install firefox with sudo apt-get --yes --force-yes install firefox .

and then ran the python code block and getting the error as posted in the comment

browser = webdriver.Firefox(options=opts, executable_path='/tmp/geckodriver')

-werners-
Esteemed Contributor III

Sorry I missed that.
You could try to install snap by adjusting/disabling apparmor.  But I doubt that will fix anything as the snap package for firefox will be the same as the firefox apt install (except with added dependencies).
Have you tried if firefox is actually working? (/path/to/firefox -headless)
Here is an interesting article: https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/

Debayan
Databricks Employee
Databricks Employee

Hi, 

This is an issue with the dependencies of different packages. 

Please try as below: 

apt get update && apt get upgrade; 

apt install firefox;

Please tag @Debayan with your next comment which will notify me. 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group