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

Unresolved import on package that is installed in kernel used in a notebook #5814

Closed
luabud opened this issue Apr 27, 2024 · 3 comments
Closed
Assignees
Labels
bug Something isn't working fixed in next version (release) A fix has been implemented and will appear in an upcoming version

Comments

@luabud
Copy link
Member

luabud commented Apr 27, 2024

Environment data

  • Language Server version: 2024.4.104
  • OS and version: linux x64 (Codespaces)
  • Python version (and distribution if applicable, e.g. Anaconda):
  • python.analysis.indexing: true
  • python.analysis.typeCheckingMode: basic

Code Snippet

https://github.com/microsoft/pylance-release/blob/main/testing/single/src/notebook.ipynb

Repro Steps

  1. Follow the set up instructions from this TPI: https://github.com/microsoft/pyrx/issues/5097
  2. Open the notebook file
  3. Create a virtual environment and install the dependencies from requirements.txt
  4. Select the virtual environment as the kernel for the notebook file
  5. Run the first cell. Notice it succeeds but Pylance doesn't recognize pytest:
    image

Logs

2024-04-26 23:52:22.289 [info] (Client) Pylance async client (2024.4.104) started with python extension (2024.5.11172159)
2024-04-26 23:52:22.823 [info] [Info  - 11:52:22 PM] (2275) Pylance language server 2024.4.104 (pyright version 1.1.360, commit 4bc8428d) starting
2024-04-26 23:52:22.823 [info] [Info  - 11:52:22 PM] (2275) Server root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist
2024-04-26 23:52:22.823 [info] [Info  - 11:52:22 PM] (2275) Starting service instance "single"
2024-04-26 23:52:22.824 [info] [Info  - 11:52:22 PM] (2275) Auto-Indent enabled
2024-04-26 23:52:22.913 [info] [Info  - 11:52:22 PM] (2275) Setting pythonPath for service "single": "/workspaces/pylance-release/testing/single/.venv/bin/python"
2024-04-26 23:52:22.913 [info] [Info  - 11:52:22 PM] (2275) Setting environmentName for service "single": "3.10.13 (.venv venv)"
2024-04-26 23:52:22.916 [info] [Info  - 11:52:22 PM] (2275) Loading configuration file at /workspaces/pylance-release/testing/single/pyrightconfig.json
2024-04-26 23:52:22.966 [info] [Info  - 11:52:22 PM] (2275) Assuming Python version 3.10.13.final.0
2024-04-26 23:52:22.967 [info] [Info  - 11:52:22 PM] (2275) No include entries specified; assuming /workspaces/pylance-release/testing/single
2024-04-26 23:52:22.968 [info] [Info  - 11:52:22 PM] (2275) Auto-excluding **/node_modules
2024-04-26 23:52:22.968 [info] [Info  - 11:52:22 PM] (2275) Auto-excluding **/__pycache__
2024-04-26 23:52:22.969 [info] [Info  - 11:52:22 PM] (2275) Auto-excluding **/.*
2024-04-26 23:52:23.345 [info] [Info  - 11:52:23 PM] (2275) Found 40 source files
2024-04-26 23:52:23.764 [info] [Info  - 11:52:23 PM] (2275) Background analysis(1) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist
2024-04-26 23:52:23.773 [info] [Info  - 11:52:23 PM] (2275) Background analysis(1) started
2024-04-26 23:52:28.655 [info] [Info  - 11:52:28 PM] (2275) Indexer background runner(2) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist (index)
2024-04-26 23:52:28.656 [info] [Info  - 11:52:28 PM] (2275) Indexing(2) started
2024-04-26 23:52:29.499 [info] [Info  - 11:52:29 PM] (2275) scanned(2) 45 files over 2 exec env
2024-04-26 23:52:30.050 [info] [Info  - 11:52:30 PM] (2275) indexed(2) 22 files over 2 exec env
2024-04-26 23:52:30.081 [info] [Info  - 11:52:30 PM] (2275) Indexing finished(2).
2024-04-26 23:57:39.558 [info] [Info  - 11:57:39 PM] (2275) Found 41 source files
2024-04-26 23:57:48.748 [info] [Info  - 11:57:48 PM] (2275) Found 40 source files
2024-04-26 23:57:52.380 [info] [Info  - 11:57:52 PM] (2275) Found 41 source files
2024-04-26 23:57:57.095 [info] [Info  - 11:57:57 PM] (2275) Found 40 source files
2024-04-26 23:58:37.628 [info] [Info  - 11:58:37 PM] (2275) Found 41 source files
2024-04-26 23:58:57.149 [info] [Info  - 11:58:57 PM] (2275) Found 40 source files
2024-04-27 00:01:20.243 [info] [Info  - 12:01:20 AM] (2275) Setting pythonPath for service "single": "/workspaces/pylance-release/testing/single/.venv/bin/python"
2024-04-27 00:01:20.243 [info] [Info  - 12:01:20 AM] (2275) Setting environmentName for service "single": "3.10.13 (.venv venv)"
2024-04-27 00:01:20.249 [info] [Info  - 12:01:20 AM] (2275) Loading configuration file at /workspaces/pylance-release/testing/single/pyrightconfig.json
2024-04-27 00:01:20.309 [info] [Info  - 12:01:20 AM] (2275) Assuming Python version 3.10.13.final.0
2024-04-27 00:01:20.310 [info] [Info  - 12:01:20 AM] (2275) No include entries specified; assuming /workspaces/pylance-release/testing/single
2024-04-27 00:01:20.312 [info] [Info  - 12:01:20 AM] (2275) Auto-excluding **/node_modules
2024-04-27 00:01:20.312 [info] [Info  - 12:01:20 AM] (2275) Auto-excluding **/__pycache__
2024-04-27 00:01:20.312 [info] [Info  - 12:01:20 AM] (2275) Auto-excluding **/.*
2024-04-27 00:01:20.474 [info] [Info  - 12:01:20 AM] (2275) Found 40 source files
2024-04-27 00:01:21.832 [info] [Info  - 12:01:21 AM] (2275) Indexer background runner(3) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist (index)
2024-04-27 00:01:21.832 [info] [Info  - 12:01:21 AM] (2275) Indexing(3) started
2024-04-27 00:01:22.768 [info] [Info  - 12:01:22 AM] (2275) scanned(3) 45 files over 2 exec env
2024-04-27 00:01:23.242 [info] [Info  - 12:01:23 AM] (2275) indexed(3) 22 files over 2 exec env
2024-04-27 00:01:23.295 [info] [Info  - 12:01:23 AM] (2275) Indexing finished(3).
2024-04-27 00:02:27.393 [info] [Info  - 12:02:27 AM] (2275) Found 40 source files
2024-04-27 00:34:03.534 [info] [Info  - 12:34:03 AM] (2275) Setting pythonPath for service "single": "/workspaces/pylance-release/testing/single/.venv/bin/python"
2024-04-27 00:34:03.534 [info] [Info  - 12:34:03 AM] (2275) Setting environmentName for service "single": "3.10.13 (.venv venv)"
2024-04-27 00:34:03.535 [info] [Info  - 12:34:03 AM] (2275) Loading configuration file at /workspaces/pylance-release/testing/single/pyrightconfig.json
2024-04-27 00:34:03.610 [info] [Info  - 12:34:03 AM] (2275) Assuming Python version 3.10.13.final.0
2024-04-27 00:34:03.610 [info] [Info  - 12:34:03 AM] (2275) No include entries specified; assuming /workspaces/pylance-release/testing/single
2024-04-27 00:34:03.610 [info] [Info  - 12:34:03 AM] (2275) Auto-excluding **/node_modules
2024-04-27 00:34:03.610 [info] [Info  - 12:34:03 AM] (2275) Auto-excluding **/__pycache__
2024-04-27 00:34:03.610 [info] [Info  - 12:34:03 AM] (2275) Auto-excluding **/.*
2024-04-27 00:34:03.779 [info] [Info  - 12:34:03 AM] (2275) Found 40 source files
2024-04-27 00:34:05.074 [info] [Info  - 12:34:05 AM] (2275) Indexer background runner(4) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist (index)
2024-04-27 00:34:05.075 [info] [Info  - 12:34:05 AM] (2275) Indexing(4) started
2024-04-27 00:34:05.590 [info] [Info  - 12:34:05 AM] (2275) scanned(4) 45 files over 2 exec env
2024-04-27 00:34:06.044 [info] [Info  - 12:34:06 AM] (2275) indexed(4) 22 files over 2 exec env
2024-04-27 00:34:06.083 [info] [Info  - 12:34:06 AM] (2275) Indexing finished(4).
2024-04-27 00:34:16.195 [info] [Info  - 12:34:16 AM] Server process exited successfully
2024-04-27 00:34:16.723 [info] (Client) Pylance async client (2024.4.104) started with python extension (2024.5.11172159)
2024-04-27 00:34:17.078 [info] [Info  - 12:34:17 AM] (18515) Pylance language server 2024.4.104 (pyright version 1.1.360, commit 4bc8428d) starting
2024-04-27 00:34:17.078 [info] [Info  - 12:34:17 AM] (18515) Server root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist
2024-04-27 00:34:17.084 [info] [Info  - 12:34:17 AM] (18515) Starting service instance "single"
2024-04-27 00:34:17.093 [info] [Info  - 12:34:17 AM] (18515) Auto-Indent enabled
2024-04-27 00:34:17.093 [info] [Info  - 12:34:17 AM] (18515) Auto format for strings enabled
2024-04-27 00:34:17.161 [info] [Info  - 12:34:17 AM] (18515) Setting pythonPath for service "single": "/workspaces/pylance-release/testing/single/.venv/bin/python"
2024-04-27 00:34:17.161 [info] [Info  - 12:34:17 AM] (18515) Setting environmentName for service "single": "3.10.13 (.venv venv)"
2024-04-27 00:34:17.163 [info] [Info  - 12:34:17 AM] (18515) Loading configuration file at /workspaces/pylance-release/testing/single/pyrightconfig.json
2024-04-27 00:34:17.207 [info] [Info  - 12:34:17 AM] (18515) Assuming Python version 3.10.13.final.0
2024-04-27 00:34:17.209 [info] [Info  - 12:34:17 AM] (18515) No include entries specified; assuming /workspaces/pylance-release/testing/single
2024-04-27 00:34:17.209 [info] [Info  - 12:34:17 AM] (18515) Auto-excluding **/node_modules
2024-04-27 00:34:17.209 [info] [Info  - 12:34:17 AM] (18515) Auto-excluding **/__pycache__
2024-04-27 00:34:17.209 [info] [Info  - 12:34:17 AM] (18515) Auto-excluding **/.*
2024-04-27 00:34:17.306 [info] [Info  - 12:34:17 AM] (18515) Found 40 source files
2024-04-27 00:34:18.254 [info] [Info  - 12:34:18 AM] (18515) Background analysis(1) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist
2024-04-27 00:34:18.326 [info] [Info  - 12:34:18 AM] (18515) Background analysis(1) started
2024-04-27 00:34:18.789 [info] [Info  - 12:34:18 AM] (18515) Indexer background runner(2) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist (index)
2024-04-27 00:34:18.789 [info] [Info  - 12:34:18 AM] (18515) Indexing(2) started
2024-04-27 00:34:20.103 [info] [Info  - 12:34:20 AM] (18515) scanned(2) 45 files over 2 exec env
2024-04-27 00:34:20.575 [info] [Info  - 12:34:20 AM] (18515) indexed(2) 22 files over 2 exec env
2024-04-27 00:34:20.626 [info] [Info  - 12:34:20 AM] (18515) Indexing finished(2).
2024-04-27 00:38:42.262 [info] [Info  - 12:38:42 AM] Server process exited successfully
2024-04-27 00:38:43.028 [info] (Client) Pylance async client (2024.4.104) started with python extension (2024.5.11172159)
2024-04-27 00:38:43.557 [info] [Info  - 12:38:43 AM] (20205) Pylance language server 2024.4.104 (pyright version 1.1.360, commit 4bc8428d) starting
2024-04-27 00:38:43.557 [info] [Info  - 12:38:43 AM] (20205) Server root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist
2024-04-27 00:38:43.565 [info] [Info  - 12:38:43 AM] (20205) Starting service instance "single"
2024-04-27 00:38:43.575 [info] [Info  - 12:38:43 AM] (20205) Auto-Indent enabled
2024-04-27 00:38:43.575 [info] [Info  - 12:38:43 AM] (20205) Auto format for strings enabled
2024-04-27 00:38:43.633 [info] [Info  - 12:38:43 AM] (20205) Setting pythonPath for service "single": "/workspaces/pylance-release/testing/single/.venv/bin/python"
2024-04-27 00:38:43.633 [info] [Info  - 12:38:43 AM] (20205) Setting environmentName for service "single": "3.10.13 (.venv venv)"
2024-04-27 00:38:43.635 [info] [Info  - 12:38:43 AM] (20205) Loading configuration file at /workspaces/pylance-release/testing/single/pyrightconfig.json
2024-04-27 00:38:43.742 [info] [Info  - 12:38:43 AM] (20205) Assuming Python version 3.10.13.final.0
2024-04-27 00:38:43.743 [info] [Info  - 12:38:43 AM] (20205) No include entries specified; assuming /workspaces/pylance-release/testing/single
2024-04-27 00:38:43.748 [info] [Info  - 12:38:43 AM] (20205) Auto-excluding **/node_modules
2024-04-27 00:38:43.748 [info] [Info  - 12:38:43 AM] (20205) Auto-excluding **/__pycache__
2024-04-27 00:38:43.748 [info] [Info  - 12:38:43 AM] (20205) Auto-excluding **/.*
2024-04-27 00:38:43.827 [info] [Info  - 12:38:43 AM] (20205) Found 40 source files
2024-04-27 00:38:45.096 [info] [Info  - 12:38:45 AM] (20205) Background analysis(1) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist
2024-04-27 00:38:45.105 [info] [Info  - 12:38:45 AM] (20205) Background analysis(1) started
2024-04-27 00:38:45.680 [info] [Info  - 12:38:45 AM] (20205) Indexer background runner(2) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist (index)
2024-04-27 00:38:45.680 [info] [Info  - 12:38:45 AM] (20205) Indexing(2) started
2024-04-27 00:38:48.358 [info] [Info  - 12:38:48 AM] (20205) scanned(2) 45 files over 2 exec env
2024-04-27 00:38:49.106 [info] [Info  - 12:38:49 AM] (20205) indexed(2) 22 files over 2 exec env
2024-04-27 00:38:49.175 [info] [Info  - 12:38:49 AM] (20205) Indexing finished(2).
2024-04-27 00:39:49.321 [info] [Info  - 12:39:49 AM] (20205) Starting service instance "single"
2024-04-27 00:39:49.725 [info] [Info  - 12:39:49 AM] (20205) Setting pythonPath for service "single": "/workspaces/pylance-release/testing/single"
2024-04-27 00:39:49.729 [info] [Info  - 12:39:49 AM] (20205) Setting environmentName for service "single": "3.10.13 (.venv venv)"
2024-04-27 00:39:49.729 [info] [Info  - 12:39:49 AM] (20205) Loading configuration file at /workspaces/pylance-release/testing/single/pyrightconfig.json
2024-04-27 00:39:49.818 [info] [Info  - 12:39:49 AM] (20205) No include entries specified; assuming /workspaces/pylance-release/testing/single
2024-04-27 00:39:49.819 [info] [Info  - 12:39:49 AM] (20205) Auto-excluding **/node_modules
2024-04-27 00:39:49.819 [info] [Info  - 12:39:49 AM] (20205) Auto-excluding **/__pycache__
2024-04-27 00:39:49.820 [info] [Info  - 12:39:49 AM] (20205) Auto-excluding **/.*
2024-04-27 00:39:49.820 [info] [Info  - 12:39:49 AM] (20205) Unable to get Python version from interpreter
2024-04-27 00:39:49.961 [info] [Info  - 12:39:49 AM] (20205) Found 40 source files
2024-04-27 00:39:51.157 [info] [Info  - 12:39:51 AM] (20205) Background analysis(3) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist
2024-04-27 00:39:51.161 [info] [Info  - 12:39:51 AM] (20205) Background analysis(3) started
2024-04-27 00:39:51.462 [info] [Info  - 12:39:51 AM] (20205) Indexer background runner(4) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist (index)
2024-04-27 00:39:51.462 [info] [Info  - 12:39:51 AM] (20205) Indexing(4) started
2024-04-27 00:39:52.573 [info] [Info  - 12:39:52 AM] (20205) scanned(4) 5 files over 2 exec env
2024-04-27 00:39:53.412 [info] [Info  - 12:39:53 AM] (20205) indexed(4) 2 files over 2 exec env
2024-04-27 00:39:53.464 [info] [Info  - 12:39:53 AM] (20205) Indexing finished(4).
2024-04-27 00:39:57.724 [info] [Info  - 12:39:57 AM] (20205) Found 66 source files
2024-04-27 00:39:57.754 [info] [Info  - 12:39:57 AM] (20205) Found 40 source files
2024-04-27 00:40:22.727 [info] [Info  - 12:40:22 AM] (20205) Found 66 source files
2024-04-27 00:40:22.736 [info] [Info  - 12:40:22 AM] (20205) Found 40 source files
2024-04-27 00:40:38.162 [info] [Info  - 12:40:38 AM] (20205) Found 40 source files
2024-04-27 00:40:38.175 [info] [Info  - 12:40:38 AM] (20205) Found 66 source files
2024-04-27 00:40:50.324 [info] [Info  - 12:40:50 AM] (20205) Found 40 source files
2024-04-27 00:40:50.352 [info] [Info  - 12:40:50 AM] (20205) Found 66 source files
2024-04-27 00:41:22.859 [info] [Info  - 12:41:22 AM] (20205) Indexer background runner(5) root directory: file:///home/codespace/.vscode-remote/extensions/ms-python.vscode-pylance-2024.4.104/dist (refresh)
2024-04-27 00:41:22.859 [info] [Info  - 12:41:22 AM] (20205) Indexing(5) started
2024-04-27 00:41:23.570 [info] [Info  - 12:41:23 AM] (20205) scanned(5) 93 files over 2 exec env
2024-04-27 00:41:24.575 [info] [Info  - 12:41:24 AM] (20205) indexed(5) 64 files over 2 exec env
2024-04-27 00:41:24.627 [info] [Info  - 12:41:24 AM] (20205) Indexing finished(5).

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Apr 27, 2024
@luabud
Copy link
Member Author

luabud commented Apr 27, 2024

Not sure if it's related, but I can also not see the hover info on "os":

image

@rchiodo
Copy link
Contributor

rchiodo commented Apr 29, 2024

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

Although it looks like recently the notebook code changed how it indicates a kernel change. I had a PR with a fix for that:
https://github.com/microsoft/pyrx/pull/5078/files

I should submit a separate PR just for that.

@rchiodo rchiodo assigned rchiodo and unassigned bschnurr Apr 29, 2024
@rchiodo rchiodo added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Apr 29, 2024
@rchiodo rchiodo changed the title Unresolved import on package that is installed in kernel used in a notebook in Codespaces Unresolved import on package that is installed in kernel used in a notebook Apr 29, 2024
@rchiodo rchiodo added the fixed in next version (release) A fix has been implemented and will appear in an upcoming version label Apr 29, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Apr 29, 2024

This issue has been fixed in prerelease version 2024.4.105, which we've just released. You can find the changelog here: CHANGELOG.md

@rchiodo rchiodo closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (release) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants