Skip to content

Unstable import resolution in jupyter notebook #7045

@WXZhao7

Description

@WXZhao7

Environment data

  • Pylance version: [email protected]
  • OS and version: Arch, Linux 6.8.12-8-pve
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.12.9

The env is created by conda create -n test python=3.12 numpy pandas matplotlib obspy pygmt scipy -c conda-forge.

Code Snippet

nb1.ipynb, nb11.ipynb, dir1/nb1.ipynb, dir2/nb1.ipynb

import numpy
import matplotlib
import pygmt
import obspy

numpy.random.random(10)

Repro Steps

  1. create a new env with conda create -n test python=3.12 numpy pandas matplotlib obspy pygmt scipy -c conda-forge.
  2. install extensions and switch python.analysis.logLevel to Trace

Image

  1. reopen VScode and open nb1.ipynb, nb11.ipynb, dir1/nb1.ipynb, dir2/nb1.ipynb

case 1, nb11 Import "numpy" could not be resolved

Image

case 2, dir1/nb1 Import "numpy" could not be resolved

Image

case 3, both nb11 and dir1/nb1 Import "numpy" could not be resolved

Image

Actual behavior

pylance sometimes can't resolve ipynb with same or similar import correctly.

logs

case1.log
case2.log

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixed in next version (release)A fix has been implemented and will appear in an upcoming versionnotebooks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions