0

I am trying to schedule my script on pythonanywhere with a beginner account. Here is my code

class SeeTicket(webdriver.Chrome):
    def __init__(self ,driver_path='/home/saifbyte/seetickets/chromedriver.exe', teardown = False):
        options = webdriver.ChromeOptions()
        options.add_experimental_option("detach", True)
        options.add_experimental_option( 'excludeSwitches' , ['enable-logging'])
        options = options
        self.driver_path = driver_path
        self.teardown = teardown
        super(SeeTicket , self).__init__(options = options  , executable_path=self.driver_path)


        self.maximize_window()

but when I am scheduling this task , i get the following error:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

whole traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/saifbyte/seetickets/chromedriver.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/saifbyte/seetickets/seeticket_script.py", line 3, in <module>
    st = SeeTicket()
  File "/home/saifbyte/seetickets/Scrapers/seeticket.py", line 20, in __init__
    super(SeeTicket , self).__init__(options = options  , executable_path=self.driver_path)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 86, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

My executable path is correct but still getting error.

Alternatively are there any good alternative to pythonanywhere.

Thanks

glitch_123
  • 139
  • 12
  • PythonAnywhere is a Linux environment so you can't run Windows executables there. Also -- there's a chromedriver installed, so you should be able to run selenium code without uploading one. There's a caveat though: if you're on a free account, you will not be able to scrape, since free accounts have restricted internet access on PythonAnywhere. – caseneuve Jul 25 '22 at 08:51
  • 1
    Also, take a look at https://help.pythonanywhere.com/pages/selenium – Filip Jul 26 '22 at 11:10

1 Answers1

-1

From the Traceback I observe a linux styled path:

/home/saifbyte/seetickets/...

Presumably an non system.


Solution

You need to drop the extension of the ChromeDriver binary executable. Your effective line of code will be:

def __init__(self ,driver_path='/home/saifbyte/seetickets/chromedriver', teardown = False):
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352