microsoft / vscode-isort

Import sorting for python using the isort library.
https://marketplace.visualstudio.com/items?itemName=ms-python.isort
MIT License
91 stars 22 forks source link

The isort server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information. #316

Closed q447552640 closed 3 months ago

q447552640 commented 1 year ago

2023-08-19 01:13:09.305 [info] Name: isort 2023-08-19 01:13:09.305 [info] Module: isort 2023-08-19 01:13:09.305 [info] Python extension loading 2023-08-19 01:13:09.305 [info] Waiting for interpreter from python extension. 2023-08-19 01:13:09.305 [info] No interpreter found from setting isort.interpreter 2023-08-19 01:13:09.305 [info] Getting interpreter from ms-python.python extension for workspace d:\work\njbdbd\dreamface\DreamSpaceLiveStream 2023-08-19 01:13:09.305 [info] Python extension loaded 2023-08-19 01:13:09.305 [info] Interpreter from ms-python.python extension for d:\work\njbdbd\dreamface\DreamSpaceLiveStream: d:\work\njbdbd\dreamface\python39\python.exe 2023-08-19 01:13:09.305 [info] No interpreter found from setting isort.interpreter 2023-08-19 01:13:09.328 [info] Getting interpreter from ms-python.python extension for workspace d:\work\njbdbd\dreamface\DreamSpaceLiveStream 2023-08-19 01:13:09.328 [info] Interpreter from ms-python.python extension for d:\work\njbdbd\dreamface\DreamSpaceLiveStream: d:\work\njbdbd\dreamface\python39\python.exe 2023-08-19 01:13:09.328 [info] Server run command: d:\work\njbdbd\dreamface\python39\python.exe c:\Users\admin.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py 2023-08-19 01:13:09.328 [info] Server: Start requested. 2023-08-19 01:13:10.526 [info] Traceback (most recent call last): File "c:\Users\admin.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py", line 39, in import lsp_jsonrpc as jsonrpc ModuleNotFoundError: No module named 'lsp_jsonrpc'

2023-08-19 01:13:10.556 [info] [Error - 01:13:10] Server initialization failed. 2023-08-19 01:13:10.556 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:10.557 [info] [Info - 01:13:10] Connection to server got closed. Server will restart. 2023-08-19 01:13:10.557 [info] true 2023-08-19 01:13:10.557 [info] [Error - 01:13:10] isort client: couldn't create connection to server. 2023-08-19 01:13:10.557 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:11.168 [info] Traceback (most recent call last): File "c:\Users\admin.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py", line 39, in

2023-08-19 01:13:11.169 [info] import lsp_jsonrpc as jsonrpc ModuleNotFoundError: No module named 'lsp_jsonrpc'

2023-08-19 01:13:13.769 [info] [Error - 01:13:13] Server initialization failed. 2023-08-19 01:13:13.770 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:13.770 [info] [Info - 01:13:13] Connection to server got closed. Server will restart. 2023-08-19 01:13:13.770 [info] true 2023-08-19 01:13:13.770 [info] [Error - 01:13:13] isort client: couldn't create connection to server. 2023-08-19 01:13:13.770 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:13.770 [error] Server: Start failed: Error: Pending response rejected since connection got disposed 2023-08-19 01:13:14.365 [info] Traceback (most recent call last): File "c:\Users\admin.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py", line 39, in import lsp_jsonrpc as jsonrpc ModuleNotFoundError: No module named 'lsp_jsonrpc'

2023-08-19 01:13:14.386 [info] [Error - 01:13:14] Server initialization failed. 2023-08-19 01:13:14.386 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:14.386 [info] [Info - 01:13:14] Connection to server got closed. Server will restart. 2023-08-19 01:13:14.386 [info] true 2023-08-19 01:13:14.386 [info] [Error - 01:13:14] isort client: couldn't create connection to server. 2023-08-19 01:13:14.386 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:14.387 [info] [Error - 01:13:14] Restarting server failed 2023-08-19 01:13:14.387 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:15.303 [info] Traceback (most recent call last): File "c:\Users\admin.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py", line 39, in import lsp_jsonrpc as jsonrpc ModuleNotFoundError: No module named 'lsp_jsonrpc'

2023-08-19 01:13:15.331 [info] [Error - 01:13:15] Server initialization failed. 2023-08-19 01:13:15.331 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:15.332 [info] [Info - 01:13:15] Connection to server got closed. Server will restart. 2023-08-19 01:13:15.332 [info] true 2023-08-19 01:13:15.332 [info] [Error - 01:13:15] isort client: couldn't create connection to server. 2023-08-19 01:13:15.332 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:15.332 [info] [Error - 01:13:15] Restarting server failed 2023-08-19 01:13:15.332 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:15.799 [info] Traceback (most recent call last): File "c:\Users\admin.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\lsp_server.py", line 39, in import lsp_jsonrpc as jsonrpc ModuleNotFoundError: No module named 'lsp_jsonrpc'

2023-08-19 01:13:15.803 [info] [Error - 01:13:15] Server initialization failed. 2023-08-19 01:13:15.803 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:15.803 [info] [Error - 01:13:15] The isort server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information. 2023-08-19 01:13:15.803 [info] [Error - 01:13:15] isort client: couldn't create connection to server. 2023-08-19 01:13:15.803 [info] Message: Pending response rejected since connection got disposed Code: -32097 2023-08-19 01:13:15.803 [info] [Error - 01:13:15] Restarting server failed 2023-08-19 01:13:15.803 [info] Message: Pending response rejected since connection got disposed Code: -32097

karthiknadig commented 1 year ago

Can you run dir on this directory to ensure that it has all the needed files? c:\Users\admin.vscode\extensions\ms-python.isort-2023.10.1\bundled\tool\

Are you using any custom encoding in your OS?

loskutov commented 1 year ago

I am facing a similar issue. In my case, it's also about:

bundled/tool/lsp_server.py", line 39, in <module>
    import lsp_jsonrpc as jsonrpc
ModuleNotFoundError: No module named 'lsp_jsonrpc'

Indeed, bundled/tool is not in sys.path (update_sys_path() is only called with pathlib.Path(__file__).parent.parent / "libs")

See also https://github.com/microsoft/vscode-black-formatter/pull/286/files

karthiknadig commented 1 year ago

This seems to be the case for embedded/portable python. I am open for a PR adding the changes that were done for black to address this.

Column01 commented 10 months ago

Also having this issue, the bundled install doesn't find the modules needed. Do not want to install them to my venv for the project either. I've gotten around this so far by installing it to another environment and then I pointed the extension to that one, but that's not ideal

MiltiadisKoutsokeras commented 10 months ago

I get this error:

2024-01-30 13:01:47.361 [info] Traceback (most recent call last):
  File "<HOME FOLDER HERE>/.vscode-oss/extensions/ms-python.isort-2023.10.1-universal/bundled/tool/lsp_server.py", line 41, in <module>
    import lsprotocol.types as lsp
ModuleNotFoundError: No module named 'lsprotocol'

I use Debian Linux 11, Python 3.9.2, isort v2023.10.1, VSCodium 1.85.2 (c8a36a69377856369f139f39ee56dd3838130fbf).

MiltiadisKoutsokeras commented 9 months ago

Is there any updates on this?

karthiknadig commented 9 months ago

@MiltiadisKoutsokeras If you are not using portable python then make sure the following directory exists in the extension. <HOME>/.vscode-oss/extensions/ms-python.isort-2023.10.1-universal/bundled/lib. If it is not present then the OSS version of the extension build is broken.

MiltiadisKoutsokeras commented 7 months ago

I am coming back to this, indeed the directory <HOME>/.vscode-oss/extensions/ms-python.isort-2023.10.1-universal/bundled/lib is not present. The contents of a freshly installed plugin v2023.10.1 on VSCodium 1.88.0:

$ tree ~/.vscode-oss/extensions/ms-python.isort-2023.10.1-universal
/home/<user>/.vscode-oss/extensions/ms-python.isort-2023.10.1-universal
├── CHANGELOG.md
├── LICENSE.txt
├── NOTICE.txt
├── README.md
├── SECURITY.md
├── SUPPORT.md
├── bundled
│   └── tool
│       ├── __init__.py
│       ├── __pycache__
│       │   ├── lsp_jsonrpc.cpython-39.pyc
│       │   └── lsp_utils.cpython-39.pyc
│       ├── lsp_jsonrpc.py
│       ├── lsp_runner.py
│       ├── lsp_server.py
│       ├── lsp_utils.py
│       └── script_runner.py
├── dist
│   └── extension.js
├── icon.png
├── images
│   └── vscode-isort.gif
├── package.json
├── package.nls.json
├── runtime.txt
└── test-results.xml
karthiknadig commented 7 months ago

@MiltiadisKoutsokeras This issue is with how the package was created by whoever uploaded to the VSCodium's extension store. If you download the VSIX from the VS Code store you will see that it exists. Please raise an issue on the there. There is nothing we can do here.

nriley commented 6 months ago

I am having this problem with the official MS release of VSCode on Windows and the official VSCode store, not using VSCodium.

The problem as others have identified seems to be that the directory bundled\tool is not in the Python path.

I am using a portable Python as I am not an administrator on this computer and cannot install Python for the system. Here's what PYTHONPATH looks like prior to me doing this.

['c:\\Users\\nriley\\.vscode\\extensions\\ms-python.isort-2023.13.10681007\\bundled\\libs',
'',
'C:\\Users\\nriley\\Apps\\Python\\python311.zip',
'C:\\Users\\nriley\\Apps\\Python',
'C:\\Users\\nriley\\Apps\\Python\\Lib\\site-packages',
'C:\\Users\\nriley\\Apps\\Python\\Lib\\site-packages\\win32',
'C:\\Users\\nriley\\Apps\\Python\\Lib\\site-packages\\win32\\lib',
'C:\\Users\\nriley\\AppData\\Roaming\\Python\\venv\\3.11',
'C:\\Users\\nriley\\AppData\\Roaming\\Python\\venv\\3.11\\Lib\\site-packages']

Copying the following lines from the linked vscode-black commit and adding them to lsp_server.py fixed the issue:

BUNDLE_DIR = pathlib.Path(__file__).parent.parent
# Always use bundled server files.
update_sys_path(os.fspath(BUNDLE_DIR / "tool"), "useBundled")

Unfortunately I do not have time to submit a PR right now but did not want to get this lost, as I was somewhat confused reading this issue that the original reported problem is still a problem with a known solution and just awaiting a PR to fix.