From 9505d1b242a84060654c039575041b07b5f9c6c2 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 11 Jul 2020 12:40:29 -0700 Subject: [PATCH] Added new section on debugging import resolution problems. --- docs/import-resolution.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/import-resolution.md b/docs/import-resolution.md index 21fb1f186..988ed6df7 100644 --- a/docs/import-resolution.md +++ b/docs/import-resolution.md @@ -16,7 +16,7 @@ For absolute (non-relative) paths, Pyright resolves imports in the following ord 5. Try to resolve using a **third-party typeshed** stub. If the `typeshedPath` configured, use this instead of the typeshed stubs that are packaged with Pyright. This allows for the use of a newer or a patched version of the typeshed stdlib stubs. -6. Try to resolve using the packages installed in the configured Python environment. For more details about how to configure your Python environment for Pyright, see below. If a Python environment is configured, Pyright looks in the `lib/site-packages`, `Lib/site-packages`, or `python*/site-packages` subdirectory. If no site-packages directory can be found Pyright attempts to run the configured Python interpreter and ask it for its search paths. If no Python environment is configured, Pyright will use the default Python interpreter by invoking `python`. +6. Try to resolve using the **packages installed in the configured Python environment**. For more details about how to configure your Python environment for Pyright, see below. If a Python environment is configured, Pyright looks in the `lib/site-packages`, `Lib/site-packages`, or `python*/site-packages` subdirectory. If no site-packages directory can be found Pyright attempts to run the configured Python interpreter and ask it for its search paths. If no Python environment is configured, Pyright will use the default Python interpreter by invoking `python`. ## Configuring Your Python Environment @@ -31,3 +31,6 @@ Pyright uses the following mechanisms (in priority order) to determine which Pyt 3. If no `venv` or `defaultVenv` is specified in the config file, use the `python.pythonPath` setting. This setting is defined by the VS Code Python extension and can be configured using the Python extension’s environment picker interface. More recent versions of the Python extension no longer store the selected Python environment in the `python.pythonPath` setting and instead use a storage mechanism that is private to the extension. Pyright is able to access this through an API exposed by the Python extension. 4. As a fallback, use the default Python environment (i.e. the one that is invoked when typing `python` in the shell). + +## Debugging Import Resolution Problems +The import resolution mechanisms in Python are complicated, and Pyright offers many configuration options. If you are encountering problems with import resolution, Pyright provides additional logging that may help you identify the cause. To enable verbose logging, pass `--verbose` as a command-line argument or add the following entry to the config file `"verboseOutput": true`. If you are using the Pyright VS Code extension, the additional logging will appear in the Output tab (select “Pyright” from the menu). Please include this verbose logging when reporting import resolution bugs.