I am using lsp-pyright[1] module in doom Emacs for Python major mode. Local imports from my project are not recognized by lsp server.

I have created a pyrightconfig.json file in root directory of my folder but still issue is not resolved.

How to i tell lsp to read json config from my project root folder ?

2 Answers 2


You can include additional Python source paths with lsp-pyright-extra-paths. Here is my pyrightconfig.json for a project.

  "exclude": ["**/node_modules", "**/__pycache__"],
  "ignore": ["**/node_modules", "**/__pycache__"],
  "include": ["flextensor", "tvm"]
  "pythonPlatform": "Linux",
  "pythonVersion": "3.6",
  "reportMissingImports": true,
  "reportMissingTypeStubs": false,
  "stubPath": "typings",
  "typeCheckingMode": "basic",
  "venvPath": "/home/swarnendu/tmp/virtualenvs",
  "venv": "flextensor-venv"

Here is my Emacs setup (init.el) for pyright (ignoring remote Tramp setup). You could also use use-package for this.

  (when (executable-find "pyright")
    (unless (fboundp 'lsp-pyright-locate-python)
      (autoload #'lsp-pyright-locate-python "lsp-pyright" nil t))
    (unless (fboundp 'lsp-pyright-locate-venv)
      (autoload #'lsp-pyright-locate-venv "lsp-pyright" nil t))

    (add-hook 'python-mode-hook (lambda ()
                                  (require 'lsp-pyright)

    (defvar lsp-pyright-python-executable-cmd)
    (setq lsp-pyright-python-executable-cmd "python3")))

Here is the .dir-locals.el for the same project.

 (python-mode . (
                 (pyvenv-activate . "/home/swarnendu/tmp/virtualenvs/flextensor-venv")
                 (eval . (let (
                                (vconcat (list
                                          (expand-file-name "flextensor" (projectile-project-root))
                                          (expand-file-name "tvm" (projectile-project-root))
                           (setq lsp-pyright-extra-paths paths)))

Please check whether a similar setup works for you.


Have you checked if your pyrightconf.json file is actually found ?

You can check by skimming the log buffer for the lsp session

C-x C-b should give you a list of buffers

You can look for "window" as a keyword. In fact if the file is found or not is sent by the server in a "window" type message

  1. If your conf file is found, than it's a matter of properly filling it in
  2. If it's not, it's a matter of adding/removing roots from your lsp session (lsp-workspace-folder-add/remove)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.