Issue
I am building my first flask app and am having trouble integrating selenium. The app takes an input from an html text field, uses it to pass into a search field with selenium, then runs some code. However, I am getting the following error after entering something into the text field and hitting submit:
An error occurred in get_lyrics: Message: Service /home/vsherr/.cache/selenium/chromedriver/linux64/120.0.6099.109/chromedriver unexpectedly exited. Status code was: 127
An error occurred: Message: Service /home/vsherr/.cache/selenium/chromedriver/linux64/120.0.6099.109/chromedriver unexpectedly exited. Status code was: 127
[2023-12-29 12:30:52,471] ERROR in app: Exception on /search [POST]
Traceback (most recent call last):
File "/mnt/c/Users/vsher/Desktop/misc-coding/lyyric/search.py", line 19, in search
word_list = get_lyrics(song)
File "/mnt/c/Users/vsher/Desktop/misc-coding/lyyric/search.py", line 34, in get_lyrics
driver = webdriver.Chrome(options=options)
File "/home/vsherr/.local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/home/vsherr/.local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 50, in __init__
self.service.start()
File "/home/vsherr/.local/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 102, in start
self.assert_process_still_running()
File "/home/vsherr/.local/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 115, in assert_process_still_running
raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service /home/vsherr/.cache/selenium/chromedriver/linux64/120.0.6099.109/chromedriver unexpectedly exited. Status code was: 127
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vsherr/.local/lib/python3.10/site-packages/flask/app.py", line 1455, in wsgi_app
response = self.full_dispatch_request()
File "/home/vsherr/.local/lib/python3.10/site-packages/flask/app.py", line 869, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/vsherr/.local/lib/python3.10/site-packages/flask/app.py", line 867, in full_dispatch_request
rv = self.dispatch_request()
File "/home/vsherr/.local/lib/python3.10/site-packages/flask/app.py", line 852, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/mnt/c/Users/vsher/Desktop/misc-coding/lyyric/search.py", line 25, in search
return render_template('error.html', error_message=str(e))
File "/home/vsherr/.local/lib/python3.10/site-packages/flask/templating.py", line 151, in render_template
template = app.jinja_env.get_or_select_template(template_name_or_list)
File "/home/vsherr/.local/lib/python3.10/site-packages/jinja2/environment.py", line 1081, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/home/vsherr/.local/lib/python3.10/site-packages/jinja2/environment.py", line 1010, in get_template
return self._load_template(name, globals)
File "/home/vsherr/.local/lib/python3.10/site-packages/jinja2/environment.py", line 969, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
File "/home/vsherr/.local/lib/python3.10/site-packages/jinja2/loaders.py", line 126, in load
source, filename, uptodate = self.get_source(environment, name)
File "/home/vsherr/.local/lib/python3.10/site-packages/flask/templating.py", line 65, in get_source
return self._get_source_fast(environment, template)
File "/home/vsherr/.local/lib/python3.10/site-packages/flask/templating.py", line 99, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: error.html
127.0.0.1 - - [29/Dec/2023 12:30:52] "POST /search HTTP/1.1" 500 -
I have tried upgrading selenium and installing a number of packages, including:
pip install -U selenium
pip install --upgrade chromedriver-autoinstaller
sudo apt-get install -y chromium-browser
What might be causing this?
Edit: I have narrowed it down but still haven't solved the issue. It has to do with chromedriver not working in Ubuntu. Previous solutions have involved editing the filepath to get to the chromedriver. However, this solution has become obsolete as chromedriver no longer requires a filepath.
Solution
I fixed it! Had to do with broken dependencies / installations. Using pip install dependencies solved the first issue. Then I used sudo apt --fix-broken install
to fix all this installs. Works perfectly now.
Answered By - VSherr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.