For the people here having this problem and actually are using VS Code, you should try installing it within a virtual environment.
I personally would recommend Python UV.
Just follow the steps:
- Open CMD and type "pip install uv"
- Go to project folder and type on terminal "uv init"
- Now install the dependencies, always using "uv add" (ex: uv add pyautogui)
- Pyautogui will probably also ask you to install opencv so also type "uv add opencv-python"
Now you should be good to go.