skip to content
Notes && Anecdotes
A decorative, semi-related stock photo that adds less value than this comment.

Django autocomplete in (virtualenv) shell


  1. Create a file .pythonrc in ~/.pythonrc
# enable syntax completion
    import readline
except ImportError:
    print("Module readline not available.")
    import rlcompleter
    readline.parse_and_bind("tab: complete")
  1. Export it by adding this export to your profile file (if you use zsh, append to ~/.zprofile instead)
echo "export PYTHONSTARTUP=~/.pythonrc" >> ~/.bash_profile

Tada! After having reopened your terminal window, you should now get autocomplete when opennig up python


Want it in virutalenv? Append it to your activate file instead of your profile

echo "export PYTHONSTARTUP=$HOME/.pythonrc" >> ./env/bin/activate

Relevance of the image? “Way out” is a suggestion at a terminal! 😉