LoginSignup
2
0

More than 3 years have passed since last update.

【VSCode】PythonのlanguageServerが起動しなくなった

Posted at

突然VSCode拡張、PythonのLanguageServerのダウンロードが途中で停止してしまうようになった。
タスクバーの下に以下のような表示が出たまま、進まず。

Downloading Microsoft Python Language Server... 31634 of 32423 KB(98%)

【出力】パネルのPython Language Serverタブには、

Downloading https://pvsc.azureedge.net/python-language-server-stable/Python-Language-Server-linux-x64.0.5.31.nupkg...

と表示されており、これ以上は進まない状況。

ログファイルからは詳細が読み取れず、再起動やPython拡張の別バージョンをインストールしてみたりしたが、上手くいかず。

手動でソースをunzipし、起動できるようにしたので、手順を示す。languageServerなしでは話にならない。

環境

  • Visual Studio Code 1.43.1
  • Remote - SSH 0.50.1
  • Python Extension 2020.3.69010
  • CentOS 7

Windows 10のVScodeから、CentOS7にリモート接続している。PythonLanguageServerが起動しなかったのはCentOS上。
2020/03/23時点の環境なので、参考にする場合は注意。

languageServerの削除

Python拡張機能の本体は、~/.vscode-server/extensions/ms-python.python-YYYY.m.XXXXXの中にある。
この中のlanguageServer.0.XX.XがlanguageServer本体。

languageServerを手動で配置するので、languageServerを削除する。
配置する用のディレクトリを作成しておく。名前はlanguageServerで始まる名前であれば良いようだ(未確認)。

$ rm -rf languageServer.0.XX.X/
$ mkdir languageServer/

languageServerのDL

パネルに表示されていたURLから、languageServerをDL。
.nupkg.zipにリネームする。

~$ wget https://pvsc.azureedge.net/python-language-server-stable/Python-Language-Server-linux-x64.0.5.31.nupkg
~$ mv Python-Language-Server-linux-x64.0.5.31.nupkg Python-Language-Server-linux-x64.0.5.31.zip

展開、配置

unzipする。

~$ unzip Python-Language-Server-linux-x64.0.5.31.zip -d ~/.vscode-server/extensions/ms-python.python-2020.3.69010/languageServer/

これで展開はできたのだが、このまま起動すると権限の関係でエラーが出る。
実行ファイルであるlanguageServer/Microsoft.Python.LanguageServerに実行権限を与えておく。

~$ sudo chmod 775 ~/.vscode-server/extensions/ms-python.python-2020.3.69010/languageServer/Microsoft.Python.LanguageServer

起動

この時点で起動できる気がするのだが、起動してみると

[Error - 16:29:06] Starting client failed
Launching server using command dotnet failed.

という表示が。dotnetをインストールすればいいのだが、自分で配置するとdotnetが必要になるのはよくわからない。。。

.NETインストール

依存ライブラリ

$ yum install -y libunwind libicu

リポジトリ追加

$ rpm --import https://packages.microsoft.com/keys/microsoft.asc
$ vi /etc/yum.repos.d/dotnetdev.repo
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

インストール

$ yum list | grep dotnet
$ yum -y install dotnet-sdk-3.1.200

確認

$ dotnet --version
3.1.200

起動成功

自分の環境では、これでlanguageServerが起動した。
正直なところ意味があるのかはわからないが、settings.jsonに以下を追記するとのこと。

{
    "python.downloadLanguageServer": false,
    "python.jediEnabled": false,
}

参考

Can the language server be installed manually_ · Issue #1698 · microsoft_python-language-server
Downloading Python-Language-Server too slowly in China_ · Issue #1916 · microsoft_python-language-server

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0