Search code examples
pythonwindowspython-imaging-librarypyautogui

python PIL show image - file system error


I try to take a screenshot and display it with the following code:

import pyautogui

im = pyautogui.screenshot()
im.show()

but it says in the console Access is denied. and pops a windows error: enter image description here

same error if i save the picture and try to double click it from the explorer (not with python), but I can open it with sublime text for some reason.

code used for saving:

import pyautogui
import PIL

im = pyautogui.screenshot()
im.save(r'screenshot1.png')
im = PIL.Image.open(r'screenshot1.png')
im.show()

how do i solve this? should i change permissions on taking the screenshot somehow?


Solution

  • You need to change the startup type of your Windows license management service. Search for "Services" in your computer, and open the Services Management. Find the Windows license management service, and change the startup type to "Automatic". Press "apply" and "ok". Refer to this for visualization of the process.