Jedi: Autocompletion and Static Analysis for Python

raw JSON →
0.19.2 verified Tue May 12 auth: no python install: verified quickstart: verified

Jedi is a static analysis tool for Python, primarily used for autocompletion and goto functionality in IDEs and editor plugins. It also offers features like refactoring, code search, and finding references. The current version is 0.19.2, released on November 10, 2024. Jedi follows a regular release cadence, with updates approximately every 6-12 months.

pip install jedi
error ModuleNotFoundError: No module named 'jedi'
cause The 'jedi' package is not installed in the Python environment being used, or the Python environment where it is installed is not correctly configured in the IDE/editor.
fix
Ensure 'jedi' is installed in your active Python environment: pip install jedi or python -m pip install jedi.
error AttributeError: module 'jedi' has no attribute 'Script'
cause This typically occurs when an outdated or incompatible version of 'jedi' is installed, or when there's a conflict in the Python environment leading to the wrong 'jedi' module being loaded. The `Script` class might have moved or been removed in a newer major version, or the installed `jedi` is too old for the code trying to use `Script`.
fix
Upgrade 'jedi' to the latest version: pip install --upgrade jedi. If the issue persists, ensure no conflicting 'jedi' installations exist and try reinstalling it: pip uninstall jedi && pip install jedi.
error ImportError: cannot import name 'traverse_parents'
cause This error points to an internal inconsistency or version mismatch within the 'jedi' library or its dependencies, often due to a partial or corrupted installation, or an incompatibility with the Python version being used.
fix
Reinstall 'jedi' to ensure all its components are consistent: pip uninstall jedi && pip install jedi. If using a specific editor plugin (like jedi-vim), ensure it's compatible with your installed Python and jedi versions.
error AttributeError: module 'typing' has no attribute '_SpecialForm'
cause This error often arises from a compatibility issue between the 'jedi' library (or its components like 'jedi-language-server') and the `typing` module, particularly with older Python versions or specific setups where `typing` might be backported or have an unexpected structure.
fix
Update jedi and any related language server components to their latest versions: pip install --upgrade jedi jedi-language-server. Consider ensuring your Python environment is up-to-date, especially if you are using an older Python 3.x version.
breaking Deprecation of Python 2 support in version 0.16.0
fix Upgrade to Python 3.6 or later.
gotcha Use of deprecated 'completions' method in version 0.16.0
fix Use the 'complete' method instead.
breaking Unspecified failure during library load process.
fix Review the full test logs for detailed error messages or stack traces leading to the 'load' event to identify the root cause.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.33s 29.6M
3.10 slim (glibc) - - 0.21s 30M
3.11 alpine (musl) - - 0.47s 32.0M
3.11 slim (glibc) - - 0.35s 33M
3.12 alpine (musl) - - 0.35s 23.8M
3.12 slim (glibc) - - 0.34s 24M
3.13 alpine (musl) - - 0.38s 23.4M
3.13 slim (glibc) - - 0.34s 24M
3.9 alpine (musl) - - 0.34s 29.1M
3.9 slim (glibc) - - 0.34s 30M

A simple example demonstrating Jedi's autocompletion feature.

import jedi

source = '''
import json
json.lo
'''
script = jedi.Script(source, path='example.py')
completions = script.complete(3, len('json.lo'))
print(completions[0].name)