requests-html: PermissionError: [WinError 5] Access is denied

Taking a shot in the dark here and hoping someone can point me in the right direction as to why I’m getting this error. I have used this same script in the past without issue so I’m completely lost as to what happened. Any help/suggestions would be greatly appreciated.

from requests_html import HTMLSession

link = 'https://www.denvergov.org/property/realproperty/summary/160820474'
session = HTMLSession()
url = session.get(link)
print(url)

<Response [200]>

url.html.render()

Traceback (most recent call last):
  File "C:/Users/Nick/gfddfsf.py", line 9, in <module>
    url.html.render()
  File "C:\Users\Nick\lib\site-packages\requests_html.py", line 572, in render
    self.session.browser  # Automatycally create a event loop and browser
  File "C:\Users\Nick\lib\site-packages\requests_html.py", line 680, in browser
    self._browser = self.loop.run_until_complete(pyppeteer.launch(headless=True, args=['--no-sandbox']))
  File "C:\Users\Nick\lib\asyncio\base_events.py", line 467, in run_until_complete
    return future.result()
  File "C:\Users\Nick\lib\site-packages\pyppeteer\launcher.py", line 311, in launch
    return await Launcher(options, **kwargs).launch()
  File "C:\Users\Nick\lib\site-packages\pyppeteer\launcher.py", line 169, in launch
    **options,
  File "C:\Users\Nick\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Nick\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 26 (2 by maintainers)

Most upvoted comments

Having the same issue, with python 3.8 anyone. Have already tried all the above still not working

I recently faced a similar issue. In my case it was similar to the OP’s issue with subprocess.py and PermissionError: [WinError 5] Access is denied.

The displayed error is very misleading, but in my case there was an executable required for a subprocess, and I had only specified the directory containing the executable. Completing the path the the executable solved the issue.

Now that I have it solved, I understand the Permission Error description (the script can’t access the required executable) but that was not obvious to me when first debugging.

Try running as an administrator. I believe Windows puts restrictions on programs starting new processes like the subprocess module is trying to do in the traceback. Run through an administrator command prompt/PowerShell (obviously on an administrator account) and see if you get better results.

Hi team I am Facing the following issue

Traceback (most recent call last): File “C:/Users/Admin/AppData/Local/Programs/Python/Python37/demo9.py”, line 9, in <module> result=pytesseract.image_to_string(img) File “C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py”, line 347, in image_to_string }output_type File “C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py”, line 346, in <lambda> Output.STRING: lambda: run_and_get_output(*args), File “C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py”, line 262, in run_and_get_output return output_file.read().decode(‘utf-8’).strip() File “C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\contextlib.py”, line 119, in exit next(self.gen) File “C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py”, line 174, in save cleanup(f.name) File “C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py”, line 134, in cleanup raise e File “C:\Users\Admin\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py”, line 131, in cleanup remove(filename) PermissionError: [WinError 5] Access is denied: ‘C:\Users\Admin\AppData\Local\Temp\tess_8k7nta5f’

I got it working after a lot of debugging inside my code. In my case, the permission problem was because of the way I opened the image img = cv2.imread('G:/project/OCR/FDA.png')

Changed that code by adding a prefix ‘r’ before the path.

img = cv2.imread(r'G:/project/OCR/FDA.png')

Make sure you give the full path to the image. This worked for and got rid of the permission problem.

Can anyone check and tell if this solved your permission problem ?

switch the direction of the slashes make it like that subprocess.call(‘C://Users/tamer/AppData/Roaming/Zoom/bin/zoom.exe’)

not like that subprocess.call(‘C:\Users\tamer\AppData\Roaming\Zoom\bin\zoom.exe’)

I got mine to work by…

  1. Following the 3rd bullet under the heading INSTALLATION on this page https://pypi.org/project/pytesseract/ 1a. I installed the 64 bit executable installer from UB Mannheim 1b. Note: I didn’t think this was necessary because there was a pytesseract.exe in my C:\Users\name\AppData\Roaming\Python\Python38\Scripts directory. Apparently, that exe is for something else. Not sure.

I continued by…

  1. Adding the directory where tesseract.exe was actually installed to my windows path (see below). (Logging off and back on to the windows machine)

and… 3. Changing my code to this: 3a. Note the r in front of the strings to signify that they are ‘raw’ strings, meaning don’t use escape characters in them.

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\name\AppData\Local\Tesseract-OCR\tesseract.exe'

im5 = Image.open(r'C:\g\code\assistant\portion.png')

print(pytesseract.image_to_string(im5))

The printed output looks a little rough, but at least I got this far. (here’s a sample if you’re curious) Hw @ emaillink [help [PT MM messages [Ml calendar, contacts | tutor Pe Moura

These are theoretically the names of the shortcuts on my browser. Screenshot 2020-11-22 171438

Facing the same issue while unistall TensorFlow ==1.15 from the system

Try running as an administrator. I believe Windows puts restrictions on programs starting new processes like the subprocess module is trying to do in the traceback. Run through an administrator command prompt/PowerShell (obviously on an administrator account) and see if you get better results.

Thanks for the response but I got the same result unfortunately. This is really frustrating because it’s my computer and I’m the only user so being denied access to anything is pretty ridiculous. On top of that I’ve successfully ran the same script in the past so either it has something to do with a Windows update or I accidentally messed with something I shouldn’t have.