Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Import could not be resolved" after installing the package #6050

Open
ibobak opened this issue Jun 22, 2024 · 6 comments
Open

"Import could not be resolved" after installing the package #6050

ibobak opened this issue Jun 22, 2024 · 6 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@ibobak
Copy link

ibobak commented Jun 22, 2024

Type: Bug

The problem is that pylance continues to report error even after package installation.

The sequence of action was as on the picture. Steps to reproduce:

  1. install anaconda
  2. open attached notebook, run it under base environment. You will get an error in the last cell because the package is missing
  3. pip install gap-stat
  4. run the last cell. it works. but pylance is still reporting the problem (which does not exist any more)

The notebook is attached (rename to ipynb):
kmeans.ipynb.txt

image

Extension version: 2024.6.1
VS Code version: Code 1.90.2 (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:33:48.698Z)
OS version: Linux x64 6.4.6-060406-generic
Modes:

System Info
Item Value
CPUs Intel(R) Xeon(R) CPU E5-2696 v4 @ 2.20GHz (88 x 1197)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 1, 2, 1
Memory (System) 251.76GB (241.06GB free)
Process Argv --crash-reporter-id 27d42247-63fb-4d9e-9cb0-87d9974843dc
Screen Reader no
VM 50%
DESKTOP_SESSION ubuntu-xorg
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu-xorg
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
jchc7451:31067544
chatpanelt:31048053
dsvsc021:30996838
9c06g630:31013171
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupyter:31046869
2f103344:31071589
legacy_priority:31077528



@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jun 22, 2024
@heejaechang
Copy link
Contributor

will it go away if you close and re-open the notebook? or if you reload vsocde?

@ibobak
Copy link
Author

ibobak commented Jun 25, 2024

yes, it goes away if I close and open the notebook.

But this is not an option and here is why: I have Spark context running in this notebook, and many initialized pandas dataframes, which are quite hard to calculate. And if I close the notebook and re-open it again, I will have to re-initialize the Spark app, recalculate of my dataframes, etc., which is a hard routine and takes a lot of time. Therefore, keeping a notebook running (even with false errors from pylance) is better than closing and re-opening of it.

But anyway, it would be good to have a command in Ctrl + Shift + P named "Pylance: restart scanning of files/notebooks" which would just do the job

@ibobak
Copy link
Author

ibobak commented Jun 25, 2024

I don't know how the guys from PyCharm team did it, but they re-scan of all installed packages of the current environment just as soon as the new package arrives. It would be good to have this here too.

@ibobak
Copy link
Author

ibobak commented Jun 25, 2024

I see that this bug in "needs repro" status. I don't know if you noticed this: I provided a notebook file in my original message, together with steps to reproduce.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 25, 2024

This could be this issue here:
microsoft/vscode#199800

The root cause of the problem is you change your kernel and we (Pylance) never get told about it. So we think the current interpreter is a different one.

That's why Heejae asked if it went away if you closed and opened the notebook, we get the initial interpreter correctly then.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 1, 2024

The log from the Pylance Language Server should tell us which interpreter we think is being used. (If it's the VS code issue I mentioned, it won't match the kernel).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants