microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
910 stars 130 forks source link

Couldn't start client Python Tools. Launching server using command /root/.vscode-server/extensions/ms-python.python-2021.6.944021595/languageServer.0.5.59/Microsoft.Python.LanguageServer failed. #2153

Closed rswe closed 3 years ago

rswe commented 3 years ago

Environment data

Connect to container created from Ubuntu 18.04 image:

# Open in Linux -------
# Go to the folder containing your git repos and hold shift and right click and then click on "Open Linux Shell here"
# Variables
win_home=$(wslpath "$(wslvar USERPROFILE)")
image_name='reg.azurecr.io/repo/baseimages/azdo-base-images-gitpython:0.3.56750'

# Runs the container - in detached mode
docker run -t -d -e HTTP_PROXY=http://bla.com:9000 \
-e HTTPS_PROXY=http://proxy.bla.com:9000 \
-e http_proxy=http://proxy.bla.com:9000 \
-e https_proxy=http://proxy.bla.com:9000 \
-e no_proxy=.bla.com \
-v $(pwd):/root/git -v $win_home/.bash_history:/root/.bash_history \
-v $win_home/.vscode/extensions:/root/.vscode-server/extensions/ \
-v $win_home/AppData/Roaming/Code/User/settings.json:/root/.config/Code/User/settings.json \
--name my_gitpython \
$image_name /bin/bash

This script will run the docker image with name on your local docker instance and will:

Actual behavior

Notifications: Couldn't start client Python Tools Source: Python (Extension)

Expected behavior

Python extension starts successfully.

Steps to reproduce:

Click .py file to trigger Microsoft Python language server

Logs

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

Python:

Python interpreter path: /usr/bin/python3

pyenv root conda --version python3.7 -c "import sys;print(sys.executable)" python3.6 -c "import sys;print(sys.executable)" python3 -c "import sys;print(sys.executable)" python2 -c "import sys;print(sys.executable)" python -c "import sys;print(sys.executable)" /usr/bin/python3 -c "import sys;print(sys.executable)" conda info --json Starting Microsoft Python language server.

Log (Window):

[2021-06-21 21:27:17.025] [renderer7] [error] Cannot read property 'replace' of undefined: TypeError: Cannot read property 'replace' of undefined at Object.o [as mnemonicMenuLabel] (file:///C:/Users/user1/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:75:37299) at x. (file:///C:/Users/user1/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1926:3884) at n.fire (file:///C:/Users/user1/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:60:1855) at L.runner (file:///C:/Users/user1/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:662:6717) at L.doRun (file:///C:/Users/user1/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:68:17772) at L.onTimeout (file:///C:/Users/user1/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:68:17738) [2021-06-21 21:35:57.909] [renderer7] [error] spawn /root/.vscode-server/extensions/ms-python.python-2021.6.944021595/languageServer.0.5.59/Microsoft.Python.LanguageServer ENOENT: Error: spawn /root/.vscode-server/extensions/ms-python.python-2021.6.944021595/languageServer.0.5.59/Microsoft.Python.LanguageServer ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19) at onErrorNT (internal/child_process.js:465:16) at processTicksAndRejections (internal/process/task_queues.js:80:21) [2021-06-21 21:35:58.888] [renderer7] [error] Launching server using command /root/.vscode-server/extensions/ms-python.python-2021.6.944021595/languageServer.0.5.59/Microsoft.Python.LanguageServer failed.

Log (Shared):

[2021-06-21 08:57:12.978] [sharedprocess] [info] Starting to clean up unused language packs. ... [2021-06-21 21:26:35.901] [sharedprocess] [warning] Resolved variables received without matching request 13 [2021-06-21 21:26:35.901] [sharedprocess] [warning] Resolved variables received without matching request 14 [2021-06-21 21:26:35.902] [sharedprocess] [warning] Resolved variables received without matching request 15

-## no errors in other OUTPUT views.

Permissions Check:

root@3f4f9bcada6b:~/.vscode-server/extensions/ms-python.python-2021.6.944021595# ls -al | grep languageServer drwxrwxrwx 1 1000 1000 4096 Jun 18 10:31 languageServer.0.5.59

root@3f4f9bcada6b:~/.vscode-server/extensions/ms-python.python-2021.6.944021595/languageServer.0.5.59# ls -ltra | grep LanguageServer -rwxrwxrwx 1 1000 1000 101830 Jun 18 10:31 Microsoft.Python.LanguageServer.deps.json -rwxrwxrwx 1 1000 1000 253832 Jun 18 10:31 Microsoft.Python.LanguageServer.dll -rwxrwxrwx 1 1000 1000 184240 Jun 18 10:31 Microsoft.Python.LanguageServer.exe -rwxrwxrwx 1 1000 1000 84576 Jun 18 10:31 Microsoft.Python.LanguageServer.pdb -rwxrwxrwx 1 1000 1000 215 Jun 18 10:31 Microsoft.Python.LanguageServer.runtimeconfig.json

Notes:

Python Extension works fine on laptop directly (Windows 10) opening .py file Python Extension works fine when using VSCode: Add Development Container Configuration Files.... e.g. python3 Then Reopen Folder in Container...

karthiknadig commented 3 years ago

Can you please try JediLSP or Pylance as the language server?

rswe commented 3 years ago

Re-worked with Debian rather than Ubuntu for WSL (to reduce memory), and ran container to use for python dev as follows:

win_home=$(wslpath "c:\\users\\user11")
image_name='reg1.azurecr.io/myrepo/myimagepythonetc:0.1.57998'

# Runs the container - in detached mode
docker run -t -d -e HTTP_PROXY=http://bla.com:9000 \
-e HTTPS_PROXY=http://bla.com:9000 \
-e http_proxy=http://bla.com:9000 \
-e https_proxy=http://bla.com:9000 \
-e no_proxy=.bla.com \
-v $(pwd):/root/git -v $HOME/.bash_history:/root/.bash_history \
-v $win_home/.vscode/extensions:/root/.vscode-server/extensions/ \
--name my_swissknife \
$image_name /bin/bash

VSCode settings: In container, set Python: Language Server = Jedi

Ran python linting again Success. Which is better to use - Jedi or JediLSP, or pylance? I'm assuming that the Output - Python errors below can be ignored? But it doesn't appear to stop the basic linting functionality working at least.

VSCode settings: In container Python: Language Server = pylance

Success.

Output - Python:

Starting Pylance language server. Error 2021-06-22 21:35:04: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://attached-container+7b22636f6e7461696e65724e616d65223a222f6d795f73776973736b6e696665227d/root/.config/Code/User/settings.json' (Error: Unable to resolve non-existing file 'vscode-remote://attached-container+7b22636f6e7461696e65724e616d65223a222f6d795f73776973736b6e696665227d/root/.config/Code/User/settings.json') at _handleError (/root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/out/vs/server/remoteExtensionHostProcess.js:84:155535) at async y.readText (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:9:343940) at async p.doesFileNeedToBeFixed (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:581700) at async /root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:580827 at async Promise.all (index 0) at async p.getFilesToBeFixed (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:580773) at async p.updateTestSettings (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:580400)] { code: 'FileNotFound' }

conda --version

VSCode settings: In container Python: Language Server = JediLSP

Success

Output - Python:

Python interpreter path: /usr/bin/python3

pyenv root conda --version python3.7 -c "import sys;print(sys.executable)" python3.6 -c "import sys;print(sys.executable)" python3 -c "import sys;print(sys.executable)" python2 -c "import sys;print(sys.executable)" python -c "import sys;print(sys.executable)" /usr/bin/python3 -c "import sys;print(sys.executable)" conda info --json Starting Jedi language server. Error 2021-06-22 21:38:02: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://attached-container+7b22636f6e7461696e65724e616d65223a222f6d795f73776973736b6e696665227d/root/.config/Code/User/settings.json' (Error: Unable to resolve non-existing file 'vscode-remote://attached-container+7b22636f6e7461696e65724e616d65223a222f6d795f73776973736b6e696665227d/root/.config/Code/User/settings.json') at _handleError (/root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/out/vs/server/remoteExtensionHostProcess.js:84:155535) at async y.readText (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:9:343940) at async p.doesFileNeedToBeFixed (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:581700) at async /root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:580827 at async Promise.all (index 0) at async p.getFilesToBeFixed (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:580773) at async p.updateTestSettings (/root/.vscode-server/extensions/ms-python.python-2021.6.944021595/out/client/extension.js:59:580400)] { code: 'FileNotFound' } conda --version

jakebailey commented 3 years ago

Those setting errors are a red herring; they don't impact any language server.

You should see a Python Language Server output window in all of these cases that shows whether or not things loaded.

The old language server ("Microsoft") is not actively developed, so you probably want to be using Pylance or JediLSP.

rswe commented 3 years ago

ah ok. Python Language Server output looked good for Pylance and JediLSP. For reference (will not be using these):

So I think the issue much have been image related in some way (now using a different self-created image, and WSL with Debian rather than Ubutu), as I can't get it to fail now with any Python Language setting. Red herring as you say. Good to get that info re Language servers being developed, many thanks