pylance giving false negative import error in vscode

52 Views Asked by At

I succesfully connect jupyter notebook in external server linux in my organization http://100.96.0.29:8888/?token=... through vscode in my laptop windows.

I also succesfully installed some dependencies such as cupy through first cell %pip install cupy.

I also succesfully import cupy through second cell:

import cupy as cp #Import "cupy" could not be resolved Pylance(reportMissingImport)

x_gpu = cp.array([1, 2, 3])
x_gpu

Giving me output:

array([1, 2, 3])

But, why pylance report missing import?

enter image description here

1

There are 1 best solutions below

0
MingJie-MSFT On

You've installed cupy on the remote Jupyter server, not on your local machine.

Pylance doesn't know about the packages installed on the remote Jupyter server, so it reports a missing import when you try to import cupy.

One way is to install cupy on your local machine. But this seems to contradict the original intention of using remote.

Another way is to disable the warning provided by Pylance, you could add the following codes to your settings.json:

"python.analysis.diagnosticSeverityOverrides": {
    "reportMissingImports": "none"
}