1

I installed pyautogui module on python3 (only python ver. I have installed on my pc), but for some reason visual studio is not detecting it. I import it the following way: "import pyautogui"

I tried reinstalling it etc, but nothing helped.

user844179
  • 9
  • 1
  • 3
  • Does this answer your question? [Unable to import pyautogui](https://stackoverflow.com/questions/39479179/unable-to-import-pyautogui) – Shunya Jan 17 '22 at 09:40

3 Answers3

0

Solution 1

Check if there is no more python version.

  1. Press Ctrl + Shift + P to open a new command pallete.

  2. Find Jupyter: Select Interpreter to start Jupyter server

  3. Pick your python version.

Solution 2

If you are working with Visual Studio Code and import any library, you will face this error: "unresolved import". To resolve this error, In your workspace settings, you can set your Python path like the following.

  1. Press Ctrl + Shift + P to open a new command pallete.
  2. Find Preferences: Open Workspace Settings (JSON)
  3. Add code and edit path:
{
   "python.defaultInterpreterPath": "/path/to/your/venv/bin/python",
}
Jdam0xff
  • 9
  • 2
0

It looks like the python environment which you have installed the pyautogui was not the python environment you have selected in the VSCode.

You can get where you have installed the pyautogui through pip show pyautogui.

You can click the python interpreter version on the bottom-left of the VSCode to switch your python interpreter or reinstall the pyautogui in the selected environment.

After you select the environment in the VSCode, you can open a new terminal in the VSCode through Ctrl+Shift+`. The Python extension will help you activate the environment in the terminal and the package will be installed into the selected python environment.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
0

Not sure is anyone still having this issue, but i corrected it by installing the phyautogui module by using 'pip install pyautogui' on win cmd.

just run it and will be automatically recognized by visual studio.

Remember that you need phyton path installed on windows in order to run pip on cmd