Skip to content

Instantly share code, notes, and snippets.

@hwine
hwine / 00-detect-virtualenv-sitepackages.py
Created July 7, 2017 02:59 — forked from henriquebastos/00-detect-virtualenv-sitepackages.py
IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
"""IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
IPython can detect virtualenv's path and injects it's site-packages dirs into sys.path.
But it can go wrong if IPython's python version differs from VIRTUAL_ENV's.
This module fixes it looking for the actual directories. We use only old stdlib
resources so it can work with as many Python versions as possible.
References:
http://stackoverflow.com/a/30650831/443564