Skip to content

Server initialization failed (ModuleNotFoundError: No module named 'packaging') when using bundled Mypy #148

Closed

Description

Observed on pre-release v2023.3.12551007.

Steps

  • One of:
    • On Linux (e.g., Ubuntu 20.04.6 with Python installed from ppa:deadsnakes/ppa; see below)
      • Python: Select Interpreter -> /usr/bin/python3.10
      • Python: Select Interpreter -> /usr/bin/python3.11
    • On Mac
  • Open a Python source file and add i: int = "1"

Results

2023-09-14 18:36:07.066 [info] Traceback (most recent call last):

2023-09-14 18:36:07.066 [info]   File "/home/.../.vscode-server/extensions/ms-python.mypy-type-checker-2023.3.12551007/bundled/tool/lsp_server.py", line 18, in <module>

2023-09-14 18:36:07.066 [info]     from packaging.version import Version

2023-09-14 18:36:07.067 [info] ModuleNotFoundError: No module named 'packaging'

2023-09-14 18:36:07.076 [info] [Error - 6:36:07 PM] Server initialization failed.
2023-09-14 18:36:07.076 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-09-14 18:36:07.076 [info] [Error - 6:36:07 PM] The Mypy Type Checker server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
2023-09-14 18:36:07.076 [info] [Error - 6:36:07 PM] Mypy Type Checker client: couldn't create connection to server.
2023-09-14 18:36:07.076 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2023-09-14 18:36:07.076 [info] [Error - 6:36:07 PM] Restarting server failed
2023-09-14 18:36:07.076 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 

Switching the Python interpreter to one that lives in a virtual env and that has Mypy installed (e.g., via /path/to/venv/bin/pip install mypy) corrects the above problem. It seems like the bundled version is missing prerequisites?


Python installation on Ubuntu was as follows:

sudo add-apt-repository --yes ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install --yes \
  python3.10 \
  python3.10-dev \
  python3.10-venv \
  python3.11 \
  python3.11-dev \
  python3.11-venv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions