End User Usage¶
If you are a not an IDE Developer, the odds are that you just want to use Jedi as a browser plugin or in the shell. Yes that’s also possible!
Jedi is relatively young and can be used in a variety of Plugins and Software. If your Editor/IDE is not among them, recommend Jedi to your IDE developers.
Sublime Text 2/3:
- Textmate (Not sure if it’s actually working)
Visual Studio Code:
- Eric IDE (Available as a plugin)
and many more!
Tab completion in the Python Shell¶
There are two different options how you can use Jedi autocompletion in
your Python interpreter. One with your custom
and one that uses
To use Jedi completion in Python interpreter, add the following in your shell
export PYTHONSTARTUP="$(python -m jedi repl)"
Then you will be able to use Jedi completer in your Python interpreter:
$ python Python 2.7.2+ (default, Jul 20 2012, 22:15:08) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.path.join().split().in<TAB> # doctest: +SKIP os.path.join().split().index os.path.join().split().insert
Using a custom
setup_readline(namespace_module=<module '__main__' from '/home/docs/checkouts/readthedocs.org/user_builds/jedi/envs/latest/bin/sphinx-build'>)¶
Install Jedi completer to
This function setups
readlineto use Jedi in Python interactive shell. If you want to use a custom
$HOME/.pythonrc.py), you can add this piece of code:
try: from jedi.utils import setup_readline setup_readline() except ImportError: # Fallback to the stdlib readline completer if it is installed. # Taken from http://docs.python.org/2/library/rlcompleter.html print("Jedi is not installed, falling back to readline") try: import readline import rlcompleter readline.parse_and_bind("tab: complete") except ImportError: print("Readline is not installed either. No tab completion is enabled.")
This will fallback to the readline completer if Jedi is not installed. The readline completer will only complete names in the global namespace, so for example:
will complete to
with both Jedi and readline, but:
will show complete to
range(10).countonly with Jedi.
You’ll also need to add
export PYTHONSTARTUP=$HOME/.pythonrc.pyto your shell profile (usually
.profileif you use bash).