Search code examples
pythonvisual-studiovisual-studio-codepyautogui

pyautogui not being recognized in Visual Studio


When I type import pyautogui it says the module is not recognized. I have pip installed it in the correct version of python. Anyone knows why?


Solution

  • After I installed the module "pyautogui" using pip, the terminal still showed that the module could not be found. (Take the global python environment as an example.)

    We can use the command "pip show pyautogui" to check where the module is installed:

    enter image description here

    In this location we can see that the file name of the module is "pyautogui", and we use "PyAutoGUI" in the code.

    enter image description here

    Solution: Therefore, we can change the file name of the module to "PyAutoGUI", or use the code "import pyautogui". However, since the "PyAutoGUI_pyautogui_win.py" file uses "import pyautogui", it is recommended that you change the code to "import pyautogui". (And all lowercase is used in the "pyautogui" official document.)

    Run:

    enter image description here