-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Ubuntu 22.04 geckodriver/firefox crashes #3861
Comments
@chainlaboratory Thanks for reporting the issue and thanks for using Colab. Your issue is likely related to the recent Ubuntu 22.04 upgrade (#3778 ) we performed. Firefox on Ubuntu 22.04, by default, is distributed as a snap package. Firefox can be installed in various other ways, for example, downloading it and ensuring the environment can discover and use it properly. As an aside, I noticed that the geckodriver that you specify in your example is from your Google Drive, which may or may not be compatible with Ubuntu 22.04. Although YMMV, riffing on the example code you provided, I was able to successfully install Firefox and geckodriver, and pull data from web pages with the following: %%shell
wget 'https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US' -O firefox.tar.bz2
tar -xjf firefox.tar.bz2
mv firefox /opt/
ln -s /opt/firefox/firefox /usr/local/bin/firefox
wget 'https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz'
tar -xzf geckodriver*.tar.gz
chmod +x geckodriver
mv geckodriver /usr/local/bin/
apt-get install libxtst6 libdbus-glib-1-2
pip install selenium webdriver_manager import os
# Add firefox-related .so files to library path
os.environ['LD_LIBRARY_PATH'] += ':/opt/firefox' from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
opts = Options()
opts.binary_location = '/usr/local/bin/firefox'
opts.add_argument('--headless')
service = Service(executable_path=GeckoDriverManager().install())
driver = webdriver.Firefox(service=service, options=opts)
driver.get('http://www.python.org')
print(driver.title) |
many thanks |
Many thanks, great work
Von: Eric Johnson ***@***.***>
Gesendet: Donnerstag, 20. Juli 2023 19:40
An: googlecolab/colabtools ***@***.***>
Cc: Daniel Siegmann ***@***.***>; Mention ***@***.***>
Betreff: Re: [googlecolab/colabtools] Upgrade Ubuntu 22.04 geckodriver/firefox crashes (Issue #3861)
Closed #3861 <#3861> as completed.
—
Reply to this email directly, view it on GitHub <#3861 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJOAT3DAI2QSZTN3CUAQDADXRFUNPANCNFSM6AAAAAA2RJPEJA> .
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
i have problem with my script help me plz pytest /usr/local/bin/ciaobot/ciao.py --indirizzo "https://www.test.it" --profilo "ciao1" ../usr/local/bin/ciao/ciao.py F [100%] =============================================================== FAILURES ================================================================ params = {'filelista': None, 'gruppo': None, 'indirizzo': 'https://www.test.it', 'messaggio': None, ...}
/usr/local/bin/ciaobot/ciao.py:34: /usr/local/lib/python3.10/dist-packages/selenium/webdriver/firefox/webdriver.py:69: in init self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f1232ca8490>
E selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1 /usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py:229: WebDriverException |
Dear Google Colab Team,
Until July 18, 2023, the following code worked perfectly:
from google.colab import drive
drive.mount('/content/drive')
!cp /content/drive/MyDrive/KI/geckodriver /usr/local/bin/geckodriver
!pip install selenium > /dev/null
!pip install pyvirtualdisplay selenium webdriver_manager > /dev/null
!apt-get update
!apt install firefox #> /dev/null
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options as FirefoxOptions
#from selenium.webdriver.common.keys import Keys
#from selenium.webdriver.common.by import By
#from selenium.webdriver import ActionChains
#from datetime import datetime, date
#import time
#import os.path
def selenium_firefox_agent(driver_path="/usr/local/bin/geckodriver"):
#def selenium_firefox_agent(driver_path="/bin/geckodriver"):
firefox_driver_path = f'{driver_path}'
user_agent = 'Mozilla'
firefox_options = FirefoxOptions()
firefox_options.add_argument("-headless")
firefox_options.add_argument("-width=1920")
firefox_options.add_argument("-height=1080")
firefox_options.set_preference("general.useragent.override", user_agent)
driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()), options=firefox_options)
driver = selenium_firefox_agent()
Since the upgrade to Ubuntu 22.04, this code no longer works, and I am receiving the following error message:
in selenium_firefox_agent(driver_path)
22 firefox_options.add_argument("-height=1080")
23 firefox_options.set_preference("general.useragent.override", user_agent)
---> 24 driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()), options=firefox_options)
25
26 #time.sleep(2)
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/firefox/webdriver.py in init(self, options, service, keep_alive)
66 keep_alive=self.keep_alive,
67 )
---> 68 super().init(command_executor=executor, options=self.options)
69
70 self._is_remote = False
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py in init(self, command_executor, keep_alive, file_detector, options)
204 self._authenticator_id = None
205 self.start_client()
--> 206 self.start_session(capabilities)
207
208 def repr(self):
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities)
289
290 caps = _create_caps(capabilities)
--> 291 response = self.execute(Command.NEW_SESSION, caps)["value"]
292 self.session_id = response.get("sessionId")
293 self.caps = response.get("capabilities")
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
344 response = self.command_executor.execute(driver_command, params)
345 if response:
--> 346 self.error_handler.check_response(response)
347 response["value"] = self._unwrap_value(response.get("value", None))
348 return response
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
243 alert_text = value["alert"].get("text")
244 raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
--> 245 raise exception_class(message, screen, stacktrace)
WebDriverException: Message: Process unexpectedly closed with status 1
I am using the latest geckodriver version 0.33.0.
Do you have any solutions to resolve this issue?
Best regards,
Daniel Siegmann
dsiegmann@bluewin.ch
The text was updated successfully, but these errors were encountered: