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

Marks local imports as "missing" #6164

Closed
GloriousGlider8 opened this issue Jul 21, 2024 · 4 comments
Closed

Marks local imports as "missing" #6164

GloriousGlider8 opened this issue Jul 21, 2024 · 4 comments
Assignees
Labels
user responded Was "waiting for user response" and they responded

Comments

@GloriousGlider8
Copy link

GloriousGlider8 commented Jul 21, 2024

Environment data

  • Language Server version: 2024.7.1
  • OS and version: win32 x64
  • Python version (and distribution if applicable, e.g. Anaconda): 3.12.1, pip
  • python.analysis.indexing: true
  • python.analysis.typeCheckingMode: off

Code Snippet

import lib.audio as aud

Repro Steps

  1. Write a local import

Expected behavior

Pylance accepts the import and shows auto-complete

Actual behavior

Pylance marks the import as "missing"

Logs

2024-07-21 09:37:57.495 [info] (Client) Pylance async client (2024.7.1) started with python extension (2024.10.0)
2024-07-21 09:37:58.517 [info] [Info  - 9:37:58 AM] (12860) Pylance language server 2024.7.1 (pyright version 1.1.369, commit 1168be71) starting
2024-07-21 09:37:58.517 [info] [Info  - 9:37:58 AM] (12860) Server root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:37:58.529 [info] [Info  - 9:37:58 AM] (12860) Starting service instance "speedtimer"
2024-07-21 09:37:58.537 [info] [Info  - 9:37:58 AM] (12860) Starting service instance "PyPlay"
2024-07-21 09:37:58.539 [info] [Info  - 9:37:58 AM] (12860) Starting service instance "languagenutCheat"
2024-07-21 09:37:58.542 [info] [Info  - 9:37:58 AM] (12860) Starting service instance "gg8lib"
2024-07-21 09:37:58.543 [info] [Info  - 9:37:58 AM] (12860) Starting service instance "testthing"
2024-07-21 09:37:58.545 [info] [Info  - 9:37:58 AM] (12860) Starting service instance "homebrew"
2024-07-21 09:37:59.487 [info] [Info  - 9:37:59 AM] (12860) Background analysis(3) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:37:59.487 [info] [Info  - 9:37:59 AM] (12860) Background analysis(3) started
2024-07-21 09:37:59.487 [info] [Info  - 9:37:59 AM] (12860) Background analysis(4) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:37:59.488 [info] [Info  - 9:37:59 AM] (12860) Background analysis(5) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:37:59.488 [info] [Info  - 9:37:59 AM] (12860) Background analysis(4) started
2024-07-21 09:37:59.496 [info] [Info  - 9:37:59 AM] (12860) Background analysis(5) started
2024-07-21 09:37:59.497 [info] [Info  - 9:37:59 AM] (12860) Background analysis(6) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:37:59.497 [info] [Info  - 9:37:59 AM] (12860) Background analysis(6) started
2024-07-21 09:37:59.504 [info] [Info  - 9:37:59 AM] (12860) Setting pythonPath for service "speedtimer": "C:\Python312\python.exe"
2024-07-21 09:37:59.504 [info] [Info  - 9:37:59 AM] (12860) Setting environmentName for service "speedtimer": "3.12.1 (global)"
2024-07-21 09:37:59.504 [info] [Info  - 9:37:59 AM] (12860) No include entries specified; assuming d:\dev\speedtimer
2024-07-21 09:37:59.505 [info] [Info  - 9:37:59 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:37:59.505 [info] [Info  - 9:37:59 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:37:59.509 [info] [Info  - 9:37:59 AM] (12860) Auto-excluding **/.*
2024-07-21 09:37:59.645 [info] [Info  - 9:37:59 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:37:59.989 [info] [Info  - 9:37:59 AM] (12860) Found 7 source files
2024-07-21 09:38:00.005 [info] [Info  - 9:38:00 AM] (12860) Background analysis(2) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:38:00.006 [info] [Info  - 9:38:00 AM] (12860) Background analysis(2) started
2024-07-21 09:38:00.006 [info] [Info  - 9:38:00 AM] (12860) Background analysis(1) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:38:00.006 [info] [Info  - 9:38:00 AM] (12860) Background analysis(1) started
2024-07-21 09:38:00.009 [info] [Info  - 9:38:00 AM] (12860) Setting pythonPath for service "PyPlay": "C:\Python312\python.exe"
2024-07-21 09:38:00.009 [info] [Info  - 9:38:00 AM] (12860) Setting environmentName for service "PyPlay": "3.12.1 (global)"
2024-07-21 09:38:00.010 [info] [Info  - 9:38:00 AM] (12860) No include entries specified; assuming d:\dev\PyPlay
2024-07-21 09:38:00.010 [info] [Info  - 9:38:00 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:38:00.010 [info] [Info  - 9:38:00 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:38:00.010 [info] [Info  - 9:38:00 AM] (12860) Auto-excluding **/.*
2024-07-21 09:38:00.115 [info] [Info  - 9:38:00 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:38:00.371 [info] [Info  - 9:38:00 AM] (12860) Found 1 source file
2024-07-21 09:38:00.376 [info] [Info  - 9:38:00 AM] (12860) Setting pythonPath for service "languagenutCheat": "C:\Python312\python.exe"
2024-07-21 09:38:00.377 [info] [Info  - 9:38:00 AM] (12860) Setting environmentName for service "languagenutCheat": "3.12.1 (global)"
2024-07-21 09:38:00.377 [info] [Info  - 9:38:00 AM] (12860) No include entries specified; assuming d:\dev\languagenutCheat
2024-07-21 09:38:00.377 [info] [Info  - 9:38:00 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:38:00.377 [info] [Info  - 9:38:00 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:38:00.377 [info] [Info  - 9:38:00 AM] (12860) Auto-excluding **/.*
2024-07-21 09:38:00.481 [info] [Info  - 9:38:00 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:38:01.081 [info] [Info  - 9:38:01 AM] (12860) Found 7 source files
2024-07-21 09:38:01.088 [info] [Info  - 9:38:01 AM] (12860) Setting pythonPath for service "gg8lib": "C:\Python312\python.exe"
2024-07-21 09:38:01.088 [info] [Info  - 9:38:01 AM] (12860) Setting environmentName for service "gg8lib": "3.12.1 (global)"
2024-07-21 09:38:01.094 [info] [Info  - 9:38:01 AM] (12860) Loading pyproject.toml file at d:\dev\gg8lib\pyproject.toml
2024-07-21 09:38:01.094 [info] [Info  - 9:38:01 AM] (12860) Pyproject file "d:\dev\gg8lib\pyproject.toml" has no "[tool.pyright]" section.
2024-07-21 09:38:01.094 [info] [Info  - 9:38:01 AM] (12860) No include entries specified; assuming d:\dev\gg8lib
2024-07-21 09:38:01.094 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:38:01.094 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:38:01.094 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/.*
2024-07-21 09:38:01.192 [info] [Info  - 9:38:01 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:38:01.402 [info] [Info  - 9:38:01 AM] (12860) Found 2 source files
2024-07-21 09:38:01.410 [info] [Info  - 9:38:01 AM] (12860) Setting pythonPath for service "testthing": "C:\Python312\python.exe"
2024-07-21 09:38:01.411 [info] [Info  - 9:38:01 AM] (12860) Setting environmentName for service "testthing": "3.12.1 (global)"
2024-07-21 09:38:01.411 [info] [Info  - 9:38:01 AM] (12860) No include entries specified; assuming d:\dev\testthing
2024-07-21 09:38:01.411 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:38:01.411 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:38:01.411 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/.*
2024-07-21 09:38:01.521 [info] [Info  - 9:38:01 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:38:01.721 [info] [Info  - 9:38:01 AM] (12860) Found 4 source files
2024-07-21 09:38:01.726 [info] [Info  - 9:38:01 AM] (12860) Setting pythonPath for service "homebrew": "C:\Python312\python.exe"
2024-07-21 09:38:01.726 [info] [Info  - 9:38:01 AM] (12860) Setting environmentName for service "homebrew": "3.12.1 (global)"
2024-07-21 09:38:01.726 [info] [Info  - 9:38:01 AM] (12860) No include entries specified; assuming d:\dev\homebrew
2024-07-21 09:38:01.727 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:38:01.727 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:38:01.727 [info] [Info  - 9:38:01 AM] (12860) Auto-excluding **/.*
2024-07-21 09:38:01.819 [info] [Info  - 9:38:01 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:38:02.726 [info] [Info  - 9:38:02 AM] (12860) No source files found.
2024-07-21 09:38:04.137 [info] [Info  - 9:38:04 AM] (12860) Starting service instance "<default>"
2024-07-21 09:38:07.481 [info] [Info  - 9:38:07 AM] (12860) Background analysis(7) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:38:07.481 [info] [Info  - 9:38:07 AM] (12860) Background analysis(7) started
2024-07-21 09:38:07.536 [info] [Info  - 9:38:07 AM] (12860) Setting pythonPath for service "<default>": "c:\Python312\python.exe"
2024-07-21 09:38:07.537 [info] [Info  - 9:38:07 AM] (12860) Setting environmentName for service "<default>": "3.12.1 (global)"
2024-07-21 09:38:07.537 [info] [Info  - 9:38:07 AM] (12860) No include entries specified; assuming \<default workspace root>
2024-07-21 09:38:07.538 [info] [Info  - 9:38:07 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:38:07.538 [info] [Info  - 9:38:07 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:38:07.575 [info] [Info  - 9:38:07 AM] (12860) Auto-excluding **/.*
2024-07-21 09:38:07.648 [info] [Info  - 9:38:07 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:38:07.897 [info] [Error - 9:38:07 AM] (12860) File or directory "\<default workspace root>" does not exist.
2024-07-21 09:38:07.897 [info] [Info  - 9:38:07 AM] (12860) No source files found.
2024-07-21 09:43:32.083 [info] [Info  - 9:43:32 AM] (12860) Starting service instance "prohub"
2024-07-21 09:43:32.533 [info] [Info  - 9:43:32 AM] (12860) Setting pythonPath for service "prohub": "C:\Python312\python.exe"
2024-07-21 09:43:32.534 [info] [Info  - 9:43:32 AM] (12860) Setting environmentName for service "prohub": "3.12.1 (global)"
2024-07-21 09:43:32.541 [info] [Info  - 9:43:32 AM] (12860) No include entries specified; assuming d:\ROMDumping\prohub
2024-07-21 09:43:32.541 [info] [Info  - 9:43:32 AM] (12860) Auto-excluding **/node_modules
2024-07-21 09:43:32.542 [info] [Info  - 9:43:32 AM] (12860) Auto-excluding **/__pycache__
2024-07-21 09:43:32.542 [info] [Info  - 9:43:32 AM] (12860) Auto-excluding **/.*
2024-07-21 09:43:32.641 [info] [Info  - 9:43:32 AM] (12860) Assuming Python version 3.12.1.final.0
2024-07-21 09:43:33.050 [info] [Info  - 9:43:33 AM] (12860) No source files found.
2024-07-21 09:43:33.054 [info] [Info  - 9:43:33 AM] (12860) Background analysis(8) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-21 09:43:33.055 [info] [Info  - 9:43:33 AM] (12860) Background analysis(8) started
2024-07-21 09:43:38.546 [info] [Info  - 9:43:38 AM] (12860) [BG(7)] Long operation: checking: file:///d%3A/dev/PyPlay/py_pl_main.pyw (2523ms)
2024-07-21 09:43:38.563 [info] [Info  - 9:43:38 AM] (12860) [BG(7)] Long operation: analyzing: file:///d%3A/dev/PyPlay/py_pl_main.pyw (2719ms)
2024-07-21 09:59:42.225 [info] [Info  - 9:59:42 AM] (12860) Indexer background runner(9) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist (index)
2024-07-21 09:59:42.225 [info] [Info  - 9:59:42 AM] (12860) Indexing(9) started
2024-07-21 09:59:44.152 [info] [Info  - 9:59:44 AM] (12860) scanned(9) 486 files over 1 exec env
2024-07-21 09:59:54.907 [info] [Info  - 9:59:54 AM] (12860) [IDX(9)] Long operation: index execution environment file:///d%3A/dev/PyPlay (10391ms)
2024-07-21 09:59:54.997 [info] [Info  - 9:59:54 AM] (12860) [IDX(9)] Long operation: index packages file:///d%3A/dev/PyPlay (10557ms)
2024-07-21 09:59:54.997 [info] [Info  - 9:59:54 AM] (12860) indexed(9) 331 files over 1 exec env
2024-07-21 09:59:55.162 [info] [Info  - 9:59:55 AM] (12860) Indexing finished(9).
2024-07-21 10:00:11.229 [info] [Info  - 10:00:11 AM] (12860) Indexer background runner(10) root directory: file:///c%3A/Users/samgp/.vscode/extensions/ms-python.vscode-pylance-2024.7.1/dist (index)
2024-07-21 10:00:11.229 [info] [Info  - 10:00:11 AM] (12860) Indexing(10) started
2024-07-21 10:00:11.437 [info] [Info  - 10:00:11 AM] (12860) Found 1 source file
2024-07-21 10:00:11.992 [info] [Info  - 10:00:11 AM] (12860) scanned(10) 486 files over 1 exec env
2024-07-21 10:00:12.848 [info] [Info  - 10:00:12 AM] (12860) indexed(10) 331 files over 1 exec env
2024-07-21 10:00:13.004 [info] [Info  - 10:00:13 AM] (12860) Indexing finished(10).
2024-07-21 10:04:45.163 [info] [Info  - 10:04:45 AM] (12860) Found 2 source files
2024-07-21 10:04:48.202 [info] [Info  - 10:04:48 AM] (12860) Found 1 source file
2024-07-21 10:04:54.883 [info] [Info  - 10:04:54 AM] (12860) Found 1 source file
2024-07-21 10:06:19.516 [info] [Info  - 10:06:19 AM] (12860) Found 1 source file
2024-07-21 10:06:24.696 [info] [Info  - 10:06:24 AM] (12860) Found 1 source file
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jul 21, 2024
@StellaHuang95
Copy link
Contributor

Can you share your project structure or a simple code sample that repros the issue?

@StellaHuang95 StellaHuang95 added waiting for user response Requires more information from user and removed needs repro Issue has not been reproduced yet labels Jul 22, 2024
@GloriousGlider8
Copy link
Author

project/
main.py
assets/
music.mp3
lib/
media.py

main.py

import lib.media as med #pylance says lib.media "does not exist"

media.load("assets/music.mp3") #no auto-complete! :(
media.play() #all code works fine when run

@github-actions github-actions bot added user responded Was "waiting for user response" and they responded and removed waiting for user response Requires more information from user labels Jul 22, 2024
@StellaHuang95
Copy link
Contributor

The runtime environment might differ from the edit-time environment, so the fact that media.play() runs does not necessarily relate to the import not resolved issue. The log you provided above doesn't seem to have trace turned on. Could you reproduce the issue with the log enabled and provide us with the logs? You can follow the instructions here to set the log level to trace: Pylance Troubleshooting Guide.

@GloriousGlider8
Copy link
Author

Never mind, it seems to have resolved the imports, I have no idea what made it work, but it does now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user responded Was "waiting for user response" and they responded
Projects
None yet
Development

No branches or pull requests

2 participants