Home > database >  PermissionError: [Errno 13] Permission denied geckodriver.exe
PermissionError: [Errno 13] Permission denied geckodriver.exe

Time:01-01

I am writing a bot for Instagram using InstaPy. I need a lot of accounts, so I use threads, but I get an error:

Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Program Files\Python\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Program Files\Python\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\User\Desktop\inst\inst.py", line 99, in follow_by_list
user_session = InstaPy(username=user.name, 
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\instapy.py", line 
327, in __init__
self.browser, err_msg = set_selenium_local_session(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\browser.py", line 
123, in set_selenium_local_session
browser = webdriver.Firefox(
File "C:\Users\User\AppData\Roaming\Python\Python39\site- 
packages\selenium\webdriver\firefox\webdriver.py", line 174, in __init__
self.service.start()
File "C:\Users\User\AppData\Roaming\Python\Python39\site- 
packages\selenium\webdriver\common\service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Program Files\Python\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 193] %1 �� �������� ����������� Win32
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Program Files\Python\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Program Files\Python\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\User\Desktop\inst\inst.py", line 99, in follow_by_list
user_session = InstaPy(username=user.name, 
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\instapy.py", line 
327, in __init__
self.browser, err_msg = set_selenium_local_session(
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\browser.py", line 
122, in set_selenium_local_session
driver_path = geckodriver_path or get_geckodriver()
File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\instapy\browser.py", line 
38, in get_geckodriver
sym_path = gdd.download_and_install()[1]
File "C:\Users\User\AppData\Roaming\Python\Python39\site- 
packages\webdriverdownloader\webdriverdownloader.py", line 225, in download_and_install
shutil.copy2(src_file, dest_file)
File "C:\Program Files\Python\lib\shutil.py", line 435, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Program Files\Python\lib\shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 
'C:\\Users\\User\\InstaPy\\assets\\geckodriver.exe'

Сode:

class User
    #...

def run():
    following = ["user1", "user2"]
    threads = []
    for user in user_accs:
        t = Thread(target=Giv.follow_by_list, args=(user, following,), group=None)
        threads.append(t)
        t.start()
  
    for t in threads:
        t.join()

def follow_by_list(user, following):
    user_session = InstaPy(username=user.name, 
                password=user.password,
                proxy_username=user.proxy_username,
                proxy_password=user.proxy_password,
                proxy_address=user.proxy_address,
                proxy_port=int(user.proxy_port))
    user_session.login()     
    user_session.follow_by_list(followlist=following, times=1, interact=False)
    user_session.end(threaded_session=True)

def main():
    run()


if __name__ == "__main__":
    main()

If I call the code for one account everything works:

#...
for user in user_accs:
    t = Thread(target=Giv.follow_by_list, args=(user, following,), group=None)
    threads.append(t)
    t.start()
    break # for one account
#...

CodePudding user response:

As each InstaPy thread tries to download_and_install() a seperate instance of GeckoDriver there seems to be resource lockage. Hence you see the error:

PermissionError: [Errno 13] Permission denied: 'C:\\Users\\User\\InstaPy\\assets\\geckodriver.exe'

An ideal solution would be to download and make make GeckoDriver readily available so any thread can use the same GeckoDriver to span a new service without downloading them individually.

  • Related