{"id":13861872,"url":"https://github.com/emacs-lsp/lsp-python-ms","last_synced_at":"2025-07-14T09:34:05.213Z","repository":{"id":50090751,"uuid":"159308412","full_name":"emacs-lsp/lsp-python-ms","owner":"emacs-lsp","description":"lsp-mode :heart: Microsoft's python language server","archived":true,"fork":false,"pushed_at":"2023-07-31T15:06:11.000Z","size":2574,"stargazers_count":189,"open_issues_count":25,"forks_count":41,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-05-15T15:35:34.731Z","etag":null,"topics":["elisp","emacs-lsp","lsp","python","python-ms"],"latest_commit_sha":null,"homepage":"https://emacs-lsp.github.io/lsp-python-ms","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emacs-lsp.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-11-27T09:19:19.000Z","updated_at":"2024-03-19T09:19:55.000Z","dependencies_parsed_at":"2022-08-03T18:45:23.060Z","dependency_job_id":"d50bc6ea-fc6d-4801-b47e-d3235ed5daa9","html_url":"https://github.com/emacs-lsp/lsp-python-ms","commit_stats":{"total_commits":231,"total_committers":35,"mean_commits":6.6,"dds":0.5108225108225108,"last_synced_commit":"7bda327bec7b219d140c34dab4b1e1fbd41bc516"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emacs-lsp%2Flsp-python-ms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emacs-lsp%2Flsp-python-ms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emacs-lsp%2Flsp-python-ms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emacs-lsp%2Flsp-python-ms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emacs-lsp","download_url":"https://codeload.github.com/emacs-lsp/lsp-python-ms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225885465,"owners_count":17539641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elisp","emacs-lsp","lsp","python","python-ms"],"created_at":"2024-08-05T06:01:31.972Z","updated_at":"2024-11-22T21:31:17.780Z","avatar_url":"https://github.com/emacs-lsp.png","language":"Emacs Lisp","funding_links":[],"categories":["Emacs Lisp"],"sub_categories":[],"readme":"[[https://github.com/emacs-lsp/lsp-python-ms/actions][https://github.com/emacs-lsp/lsp-python-ms/workflows/CI/badge.svg?branch=master]]\n[[http://img.shields.io/:License-BSD3-blue.svg]]\n[[https://melpa.org/#/lsp-python-ms][https://melpa.org/packages/lsp-python-ms-badge.svg]]\n[[https://stable.melpa.org/#/lsp-python-ms][https://stable.melpa.org/packages/lsp-python-ms-badge.svg]]\n\n=lsp-mode= client leveraging Microsoft's [[https://github.com/Microsoft/python-language-server][python-language-server]].\n\nThis project is marked as DEPRECATED, since [Microsoft's Python Lang Server](https://github.com/microsoft/python-language-server) has already been archived and is replaced by [pyright](https://github.com/microsoft/pyright). The successor is [lsp-pyright](https://github.com/emacs-lsp/lsp-pyright).\n\n* Installation\n\nInclude ~lsp-python-ms~ in the configuration file:\n#+BEGIN_SRC emacs-lisp\n(require 'lsp-python-ms)\n(setq lsp-python-ms-auto-install-server t)\n(add-hook 'python-mode-hook #'lsp) ; or lsp-deferred\n#+END_SRC\n\nA minimal ~use-package~ initialization might be:\n#+BEGIN_SRC elisp\n  (use-package lsp-python-ms\n    :ensure t\n    :init (setq lsp-python-ms-auto-install-server t)\n    :hook (python-mode . (lambda ()\n                            (require 'lsp-python-ms)\n                            (lsp))))  ; or lsp-deferred\n#+END_SRC\n\n** Installing the executable\n\n*** NixOS\n\nBuilding the executable manually is difficult on NixOS, but it can be easily installed via the package manager.\nAt the time of writing (May 2020), it is not available on the 20.03 release, but can be acquired on the unstable branch.\n\n#+begin_src bash\n    nix-channel --add https://nixos.org/channels/nixos-unstable nixos\n    nix-channel --update nixos\n#+end_src\n\nYou can then install the executable by running ~nix-env -iA nixpkgs.python-language-server~\nor by adding ~nixpkgs.python-language-server~ to your ~configuration.nix~ and creating a new generation.\nNote that ~python37Packages.python-language-server~ refers to Palintir's language server, not Microsoft's.\n\nFinally, ensure that Emacs knows where to find the executable by setting ~lsp-python-ms-executable~.\n\n#+begin_src elisp\n  (use-package lsp-python-ms\n    :ensure t\n    :hook (python-mode . (lambda ()\n                           (require 'lsp-python-ms)\n                           (lsp)))\n    :init\n    (setq lsp-python-ms-executable (executable-find \"python-language-server\")))\n\n#+end_src\n\n*** Most other distros\n\nNormally the [[https://github.com/Microsoft/python-language-server][python-language-server]] will be downloaded automatically if it doesn't\nexist while opening the python scripts.\n\nIf you have troubles to download the package, you can also build the server yourselves.\n\n1. Install [[https://www.microsoft.com/net/download][dotnet-sdk]]\n2. Clone and build [[https://github.com/Microsoft/python-language-server][python-language-server]]:\n   #+BEGIN_SRC bash\n   git clone https://github.com/Microsoft/python-language-server.git\n   cd python-language-server/src/LanguageServer/Impl\n   dotnet publish -c Release -r osx-x64   # mac\n   #+END_SRC\n\n   Change the ~-r~ flag according to your architecture and operating system.\n   See Microsoft's [[https://docs.microsoft.com/en-us/dotnet/core/rid-catalog][Runtime ID Catalog]] for the right value for your system.\n\n   Then make the binary executable.\n   #+BEGIN_SRC bash\n   chmod a+x $(git rev-parse --show-toplevel)/output/bin/Release/osx-x64/publish/Microsoft.Python.LanguageServer\n   #+END_SRC\n\n   NOTE: on some systems (for example, Fedora), the executable comes out as\n         ~Microsoft.Python.LanguageServer.LanguageServer~.\n\n3. Set executable to ~lsp-python-ms-executable~.\n\n   #+BEGIN_SRC elisp\n   ;; for executable of language server, if it's not symlinked on your PATH\n   (setq lsp-python-ms-executable\n         \"~/python-language-server/output/bin/Release/osx-x64/publish/Microsoft.Python.LanguageServer\")\n   #+END_SRC\n\nFor development, you might find it useful to run =cask install=.\n\n* FAQ\n\n1. Unresolved import warnings\n\n   Set workspace root of `lsp-mode` properly, and add the extra directories to =lsp-python-ms-extra-paths= or =PYTHONPATH=. \n   Refer to [[https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings][Troubleshooting - Unresolved import warnings]] and [[https://github.com/emacs-lsp/lsp-python-ms/issues/96][#96]].\n\n2. Autocompletion doesn't work\n\n   The folder may have huge folders and files, and  the server takes a long time to index them. So please DO NOT put huge files in the project/workspace folder.\n\n3. Set path of the Python executable for each project/workspace\n\n   Set the variable =lsp-python-ms-python-executable= before the `lsp-mode` being loaded.\n\n   First, add =hack-local-variables-hook= in `init.el` to achieve loading `lsp-mode` after the `.dir-locals.el` file of each project/workspace being loaded.\n\n   #+BEGIN_SRC emacs-lisp\n     (add-hook 'hack-local-variables-hook\n\t       (lambda ()\n\t\t (when (derived-mode-p 'python-mode)\n\t\t   (require 'lsp-python-ms)\n\t\t   (lsp)))) ; or lsp-deferred\n   #+END_SRC\n\n   Second, create `.dir-locals.el` file in the root directory of project to specify the varibale =lsp-python-ms-python-executable= for the project/workspace.\n\n   #+BEGIN_SRC emacs-lisp\n     ((python-mode . ((lsp-python-ms-python-executable . \"/.../bin/python\"))))\n   #+END_SRC\n\n* Credit\n\nAll credit to [[https://cpbotha.net][cpbotha]] on [[https://vxlabs.com/2018/11/19/configuring-emacs-lsp-mode-and-microsofts-visual-studio-code-python-language-server/][vxlabs]]! This just tidies and packages his work there.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femacs-lsp%2Flsp-python-ms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femacs-lsp%2Flsp-python-ms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femacs-lsp%2Flsp-python-ms/lists"}