1

I was running a python script that has been fine on several different distros, but is giving me trouble on Gentoo. The problem command is geckodriver_autoinstaller.install():

Traceback (most recent call last):
  File "/home/james/Gits/News_Scraper/main.py", line 5, in <module>
    from main_functions import *
  File "/home/james/Gits/News_Scraper/main_functions.py", line 25, in <module>
    from scraping_functions import *
  File "/home/james/Gits/News_Scraper/scraping_functions.py", line 19, in <module>
    geckodriver_autoinstaller.install()
  File "/home/james/Venvs/scraper_venv/lib/python3.10/site-packages/geckodriver_autoinstaller/__init__.py", line 15, in install
    geckodriver_filepath = utils.download_geckodriver(cwd)
  File "/home/james/Venvs/scraper_venv/lib/python3.10/site-packages/geckodriver_autoinstaller/utils.py", line 148, in download_geckodriver
    firefox_version = get_firefox_version()
  File "/home/james/Venvs/scraper_venv/lib/python3.10/site-packages/geckodriver_autoinstaller/utils.py", line 88, in get_firefox_version
    with subprocess.Popen(['firefox', '--version'], stdout=subprocess.PIPE) as proc:
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'firefox'

Using the Traceback I ran:

>>> subprocess.Popen(['firefox', '--version'], stdout=subprocess.PIPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'firefox'

I checked the firefox command in the shell and got a permission denied error. In my system, firefox is called firefox-bin, so I get why it didn't work, but I would have expected the error to be "command not found" instead of "permission denied". I am going on the assumption that this is the same "permission denied" that I get from within Python.

~$ which firefox
firefox not found

~$ which firefox-bin
/usr/bin/firefox-bin


I thought that maybe I could just alias `firefox-bin` to `firefox` but no luck:

~$ which firefox
firefox: aliased to firefox-bin

>>> import subprocess
>>> subprocess.Popen(['firefox', '--version'], stdout=subprocess.PIPE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'firefox'
>>> 

Was I on the wrong track thinking that this "permission denied" error displayed in Python was due to the name of the firefox executable being firefox=bin? Or perhaps setting an alias in the shell was not sufficient?

Edit: If I substitute firefox-bin for firefox in the python command, I get no error, but it also returns None.

>>> subprocess.Popen(['firefox-bin', '--version'], stdout=subprocess.PIPE)
<Popen: returncode: None args: ['firefox-bin', '--version']>

In any case, the command I am using geckodriver_autoinstaller.install() doesn't seem to have a way to specify an alternate name for the binary, so maybe I should just use a different command.

Stonecraft
  • 860
  • 1
  • 12
  • 30

0 Answers0