I am trying to use pyautogui to get a screen shot but upon simply saying import pyautogui, Visual Studio Code immediately informs me that it can't due to "Syntax error, 'source code cannot contain null bytes.'" When I run the program the console says the same. When I attempt to uninstall and reinstall pyautogui using py -m pip uninstall pyautogui I get an error, "ValueError: stat: embedded null character in path". I don't truly understand what this null character is or where it is or how to remove it. If anyone has any ideas on how I could make pyautogui usable again I would greatly appreciate it. I don't believe the problem is in my code but I'll show it anyways in case it'll get help faster.
import pyautogui
import numpy as np
import cv2
while True:
im = pyautogui.screenshot(region = (170, 425, 900, 515))
print("working")
img_np = np.array(im)
cv2.imshow('Video', img_np)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
You're likely dealing with a corrupted file. The easiest remedy is reinstallation (use pip uninstall
then reinstall), but this won't work if the corruption is in your working directory. Your next step is to manually check each file on your system (which shouldn't be too many) with pyautogui in the name and see if any of them contain something other than python code. If you find a file that does, delete it and then reinstall.