close

[Solved] “Import could not be resolved” reported by Pyright

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error “Import could not be resolved” reported by Pyright in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How “Import could not be resolved” reported by Pyright Error Occurs?

Today I get the following error “Import could not be resolved” reported by Pyright in Python.

How To Solve “Import could not be resolved” reported by Pyright Error ?

  1. How To Solve “Import could not be resolved” reported by Pyright Error ?

    To Solve “Import could not be resolved” reported by Pyright Error If you try installing it again with pip install, then it will say you already have it installed and it will give you the location where the file is, and I copied the files from there and pasted them into the correct location which is (on windows)

Solution 1

On my computer I have 3 Pythons, a 3.6 from Anaconda, and a 2.7 & 3.7 that are regular python. Prompted by a nudge from this GH issue, I switched from the Anaconda 3.6 to the 3.7, and back again, and the problem went away.

the python chooser

I think that this is the case because your .vscode/settings.json (the following is mine), doesn’t have that last line until you change your python, at which point, that last line is put in and Pyright has something to look at.

{
  "python.linting.enabled": true,
  "python.formatting.provider": "black",
  "python.pythonPath": "C:\\Users\\ben\\Anaconda3\\python.exe"
}

Solution 2

I’m not sure if you have already fixed this, but I was having a lot of troubles with stuff I got with pip install and they were installed successfully, but when I tried to import them, they didn’t import

I found out that for me, some of the installs get installed to a separate folder, and not the correct folder that they need to be in to import.

If you try installing it again with pip install, then it will say you already have it installed and it will give you the location where the file is, and I copied the files from there and pasted them into the correct location which is (on windows)

C:\Users{Username}\AppData\Local\Programs\Python{Python Version}\Lib\site-packages

I was trying to find a place to share this and this was the closest to the issue, so I hope it helps!

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment