Skip to content

no module error if module was properly imported #5865

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

Closed
Akopov4 opened this issue May 4, 2024 · 1 comment
Closed

no module error if module was properly imported #5865

Akopov4 opened this issue May 4, 2024 · 1 comment
Assignees
Labels
team needs to reproduce Issue has not been reproduced yet

Comments

@Akopov4
Copy link

Akopov4 commented May 4, 2024

Type: Bug

see attached gif. I have attached files, which i used
files.zip
import_error

Extension version: 2024.6.0
VS Code version: Code 1.89.0 (b58957e67ee1e712cebf466b995adf4c5307b2bd, 2024-05-01T02:08:25.066Z)
OS version: Linux x64 5.15.0-105-generic
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz (4 x 2500)
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) 2, 3, 2
Memory (System) 11.56GB (2.24GB free)
Process Argv --crash-reporter-id 01400cc3-0ed1-484c-a547-9fad9bdfb52d
Screen Reader no
VM 0%
DESKTOP_SESSION cinnamon
XDG_CURRENT_DESKTOP X-Cinnamon
XDG_SESSION_DESKTOP cinnamon
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
ccp1r3:30993539
dsvsc020:30976470
pythonait:31006305
chatpanelt:31018789
dsvsc021:30996838
724cj586:31013169
pythoncenvpt:31022790
dwnewjupytercf:31035177

@anthonykim1 anthonykim1 self-assigned this May 6, 2024
@anthonykim1 anthonykim1 removed their assignment May 8, 2024
@anthonykim1 anthonykim1 transferred this issue from microsoft/vscode-python May 8, 2024
@github-actions github-actions bot added the team needs to reproduce Issue has not been reproduced yet label May 8, 2024
@heejaechang
Copy link
Contributor

heejaechang commented May 8, 2024

pylance is set up in a way it can support both packages and scripts at edit time and that's why from array.core and from core both are resolved. and we expect users to set python search path properly in launch.json so import statement is resolved property under debugger.

in your case, it looks like you are trying to run a python file as a script and not from the debugger but from terminal, in that case, if you want from array.core to work, then you need to put manning_datastructure folder in sys.path

you can add it through PYTHONPATH env variable, or you can do that in code with something like sys.path.append(os.getcwd()) assuming you are running the code from manning_datstructure folder.

or you could set sys.path based on current script's location (__file__)

or you could use python -m array to run it as a module.

if you are using debugger and run it as a script, you can set this

"env": {
                "PYTHONPATH": "${workspaceFolder}"
            }

assuming your workspace root is manning_datastructure.

anyway, all that said, I believe pylance is working as expected.

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

No branches or pull requests

4 participants