microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

ModuleNotFoundError: No module named 'dataclasses' #16119

Closed rohel01 closed 3 years ago

rohel01 commented 3 years ago

Environment data

Expected behaviour

Working Python language server

Actual behaviour

As soon as vscode is started, the output window for the Python language server opens with content detailed below:

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Open vscode on a directory containing a python module

Please note I am working behind a corporate firewall, with no access to PyPI or similar. I am using the distribution default python installation.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` User belongs to experiment group 'pythonaa' User belongs to experiment group 'pythonJediLSP' User belongs to experiment group 'pythonDiscoveryModuleWithoutWatcher' User belongs to experiment group 'pythonTensorboardExperiment' User belongs to experiment group 'PythonPyTorchProfiler' User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled' User belongs to experiment group 'CollectLSRequestTiming - control' User belongs to experiment group 'DeprecatePythonPath - experiment' > python ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > python ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > python ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" > python ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" Error 2021-05-04 09:26:05: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file '/home/melchiore/src/tools/rectipy/.vscode/settings.json' (Error: Unable to resolve non-existing file '/home/melchiore/src/tools/rectipy/.vscode/settings.json') at _handleError (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87:151863) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async y.readText (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:339523) at async p.doesFileNeedToBeFixed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:577126) at async /home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:576253 at async Promise.all (index 1) at async p.getFilesToBeFixed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:576199) at async p.updateTestSettings (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:575826)] { code: 'FileNotFound' } Python interpreter path: /usr/bin/python3 Starting Jedi language server. Error 2021-05-04 09:26:05: Failed to start language server, Class name = r, completed in 791ms, has a falsy return value, Arg 1: , Arg 2: {"sysPrefix":"/usr","envType":"Unknown","envName":"","envPath":"","path":"/usr/bin/python3","architecture":3,"sysVersion":"3.6.9 (default, Jan 26 2021, 15:33:00) \n[GCC 8.4.0]","version":{"raw":"3.6.9","major":3,"minor":6,"patch":9,"build":[],"prerelease":["final","0"]},"displayName":"Python 3.6.9 64-bit"}, Arg 3: , Return Value: undefined [Error: Connection to server got closed. Server will not be restarted. at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:179488) at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:21817) at t (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:177267) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at X (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:57486) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at g.fireClose (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:47555) at Socket. (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:49135) at Socket.emit (events.js:327:22) at Pipe. (net.js:674:12)] Error 2021-05-04 09:26:05: Starting language server, Class name = r, completed in 792ms, has a falsy return value, , Return Value: undefined [Error: Connection to server got closed. Server will not be restarted. at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:179488) at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:21817) at t (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:177267) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at X (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:57486) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at g.fireClose (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:47555) at Socket. (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:49135) at Socket.emit (events.js:327:22) at Pipe. (net.js:674:12)] Error 2021-05-04 09:26:05: Failed to start language server, Class name = r, completed in 794ms, has a falsy return value, Arg 1: , Arg 2: {"sysPrefix":"/usr","envType":"Unknown","envName":"","envPath":"","path":"/usr/bin/python3","architecture":3,"sysVersion":"3.6.9 (default, Jan 26 2021, 15:33:00) \n[GCC 8.4.0]","version":{"raw":"3.6.9","major":3,"minor":6,"patch":9,"build":[],"prerelease":["final","0"]},"displayName":"Python 3.6.9 64-bit"}, Return Value: undefined [Error: Connection to server got closed. Server will not be restarted. at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:179488) at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:21817) at t (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:177267) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at X (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:57486) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at g.fireClose (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:47555) at Socket. (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:49135) at Socket.emit (events.js:327:22) at Pipe. (net.js:674:12)] Error 2021-05-04 09:26:05: [Error: Connection to server got closed. Server will not be restarted. at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:179488) at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:21817) at t (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:177267) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at X (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:57486) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at g.fireClose (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:47555) at Socket. (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:49135) at Socket.emit (events.js:327:22) at Pipe. (net.js:674:12)] We encountered an issue starting the language server. Reverting to Jedi language engine. Check the Python output panel for details. Error 2021-05-04 09:26:05: Failed to activate language server, Class name = a, completed in 796ms, has a falsy return value, Arg 1: , Arg 2: {"sysPrefix":"/usr","envType":"Unknown","envName":"","envPath":"","path":"/usr/bin/python3","architecture":3,"sysVersion":"3.6.9 (default, Jan 26 2021, 15:33:00) \n[GCC 8.4.0]","version":{"raw":"3.6.9","major":3,"minor":6,"patch":9,"build":[],"prerelease":["final","0"]},"displayName":"Python 3.6.9 64-bit"}, Return Value: undefined [Error: Connection to server got closed. Server will not be restarted. at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:179488) at E.handleConnectionClosed (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:21817) at t (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:177267) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at X (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:57486) at invoke (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:318776) at o.fire (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:9:319537) at g.fireClose (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:47555) at Socket. (/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension.js:59:49135) at Socket.emit (events.js:327:22) at Pipe. (net.js:674:12)] > conda --version > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)" cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)" cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)" cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py site --user-site cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py site --user-site cwd: ~/src/tools/rectipy > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/completion.py > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/completion.py ```

Output for Python Language Server in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python Language Server)

``` Traceback (most recent call last): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/run-jedi-language-server.py", line 9, in from jedi_language_server.cli import cli File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/cli.py", line 7, in from .server import SERVER File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/server.py", line 15, in from pygls.lsp.methods import ( File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/__init__.py", line 21, in from pygls.lsp.types import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/__init__.py", line 2, in from pygls.lsp.types.basic_structures import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/basic_structures.py", line 53, in class JsonRpcMessage(Model): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/main.py", line 298, in __new__ config=config, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 419, in infer field_info=field_info, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 342, in __init__ self.prepare() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 456, in prepare self.populate_validators() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 670, in populate_validators *(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))), File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/validators.py", line 674, in find_validators if is_builtin_dataclass(type_): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/dataclasses.py", line 79, in is_builtin_dataclass import dataclasses ModuleNotFoundError: No module named 'dataclasses' [Info - 9:26:05 AM] Connection to server got closed. Server will restart. Traceback (most recent call last): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/run-jedi-language-server.py", line 9, in from jedi_language_server.cli import cli File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/cli.py", line 7, in from .server import SERVER File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/server.py", line 15, in from pygls.lsp.methods import ( File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/__init__.py", line 21, in from pygls.lsp.types import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/__init__.py", line 2, in from pygls.lsp.types.basic_structures import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/basic_structures.py", line 53, in class JsonRpcMessage(Model): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/main.py", line 298, in __new__ config=config, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 419, in infer field_info=field_info, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 342, in __init__ self.prepare() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 456, in prepare self.populate_validators() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 670, in populate_validators *(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))), File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/validators.py", line 674, in find_validators if is_builtin_dataclass(type_): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/dataclasses.py", line 79, in is_builtin_dataclass import dataclasses ModuleNotFoundError: No module named 'dataclasses' [Info - 9:26:05 AM] Connection to server got closed. Server will restart. Traceback (most recent call last): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/run-jedi-language-server.py", line 9, in from jedi_language_server.cli import cli File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/cli.py", line 7, in from .server import SERVER File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/server.py", line 15, in from pygls.lsp.methods import ( File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/__init__.py", line 21, in from pygls.lsp.types import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/__init__.py", line 2, in from pygls.lsp.types.basic_structures import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/basic_structures.py", line 53, in class JsonRpcMessage(Model): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/main.py", line 298, in __new__ config=config, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 419, in infer field_info=field_info, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 342, in __init__ self.prepare() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 456, in prepare self.populate_validators() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 670, in populate_validators *(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))), File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/validators.py", line 674, in find_validators if is_builtin_dataclass(type_): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/dataclasses.py", line 79, in is_builtin_dataclass import dataclasses ModuleNotFoundError: No module named 'dataclasses' [Info - 9:26:05 AM] Connection to server got closed. Server will restart. Traceback (most recent call last): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/run-jedi-language-server.py", line 9, in from jedi_language_server.cli import cli File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/cli.py", line 7, in from .server import SERVER File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/server.py", line 15, in from pygls.lsp.methods import ( File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/__init__.py", line 21, in from pygls.lsp.types import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/__init__.py", line 2, in from pygls.lsp.types.basic_structures import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/basic_structures.py", line 53, in class JsonRpcMessage(Model): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/main.py", line 298, in __new__ config=config, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 419, in infer field_info=field_info, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 342, in __init__ self.prepare() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 456, in prepare self.populate_validators() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 670, in populate_validators *(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))), File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/validators.py", line 674, in find_validators if is_builtin_dataclass(type_): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/dataclasses.py", line 79, in is_builtin_dataclass import dataclasses ModuleNotFoundError: No module named 'dataclasses' [Info - 9:26:05 AM] Connection to server got closed. Server will restart. Traceback (most recent call last): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/run-jedi-language-server.py", line 9, in from jedi_language_server.cli import cli File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/cli.py", line 7, in from .server import SERVER File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/jedi_language_server/server.py", line 15, in from pygls.lsp.methods import ( File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/__init__.py", line 21, in from pygls.lsp.types import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/__init__.py", line 2, in from pygls.lsp.types.basic_structures import * File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pygls/lsp/types/basic_structures.py", line 53, in class JsonRpcMessage(Model): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/main.py", line 298, in __new__ config=config, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 419, in infer field_info=field_info, File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 342, in __init__ self.prepare() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 456, in prepare self.populate_validators() File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/fields.py", line 670, in populate_validators *(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))), File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/validators.py", line 674, in find_validators if is_builtin_dataclass(type_): File "/home/melchiore/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp/pydantic/dataclasses.py", line 79, in is_builtin_dataclass import dataclasses ModuleNotFoundError: No module named 'dataclasses' [Error - 9:26:05 AM] Connection to server got closed. Server will not be restarted. ```

karthiknadig commented 3 years ago

@rohel01 I can repro this locally. Thanks for the details.

As a work around do this:

/usr/bin/python3 -m pip install -t ~/.vscode/extensions/ms-python.python-2021.4.765268190/pythonFiles/lib/jedilsp dataclasses

That should add dataclasses to jedilsp directory and it should address this issue.

rohel01 commented 3 years ago

Tried your workaound, but it does not work in my environment: isolated network with no access to a PyPi index.

karthiknadig commented 3 years ago

isolated network with no access to a PyPi index.

@rohel01 In this set the python.languageServer setting to Jedi.

rohel01 commented 3 years ago

@karthiknadig As specified in the bug report, I am already using Jedi as my PLS. Do you mean JediLSP ?

karthiknadig commented 3 years ago

If you have it set to Jedi should not get this error. If you look closely at the error stack (in your bug report), you see that it mentions JediLSP in the path. This means the extension seem to think you are using JediLSP or there is a setting some where in the workspace that is telling the extension to use JediLSP.

If you have not set JediLSP as the language server anywhere, and have explicitly set Jedi as the language server then you should not get "No module named 'dataclasses'" error. That only happens with JediLSP.

If you have not explicitly set the LS as Jedi, then you might be in an experiment group. You can opt-out by adding this to your setting: "python.experiments.optOutFrom": ["pythonJediLSP"],

rohel01 commented 3 years ago

I have checked my settings and I have not set JediLSP anywhere. Still, I see there is a dedicated setting to set the Jedi path which I also have not set. Maybe this is a mandatory setting when using Jedi so maybe the extension is falling back to JediLSP ?

karthiknadig commented 3 years ago

there is a dedicated setting to set the Jedi path

You don't have to add that. That is only used in cases where you don't want to use the built in Jedi.

I think the best option until we fix this is to use the opt-out. So add these two to your User settings.json:

"python.languageServer": "Jedi",
"python.experiments.optOutFrom": ["pythonJediLSP"],

and add this to your work space setting:

"python.languageServer": "Jedi",

You will have to reload VS Code after adding these.

luabud commented 3 years ago

This is addressed in main now.

karthiknadig commented 3 years ago

Fixed via #16124. This ensures dataclasses is installed along with JediLSP.

rohel01 commented 3 years ago

Thank you for the quick support. When is the next release planned ?

karthiknadig commented 3 years ago

It is planned for Monday May 10th (#16010)