While working with Python Virtualenvs / Virtual Environments we ran into a package that simply refused to install into it: sqlite:

(venv) [siteowner@server /share/sites/www.sitename.com]$ pip install sqlite
Collecting sqlite
  Using cached sqlite-99.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-build-USy81K/sqlite/setup.py", line 2, in 
        raise RuntimeError("Package 'sqlite' must not be downloaded from pypi")
    RuntimeError: Package 'sqlite' must not be downloaded from pypi

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-USy81K/sqlite/

The fundamental issue is that in order to build sqlite a lot of dependencies would need to be duplicated into the virtualenv directory, but would not get garbage collected. You can read more about it in this github bug report which has been closed yet I don’t believe in a way that fixes this.

The good news is there is an easy work around: enable your virtualenv to use the system’s (global) site pacakges. This is disabled by default and needs to be enabled when creating the virtualenv via:

virtualenv --system-site-packages venvdir

You then simply install the sqlite pip package globally either via pip outside of the virtualenv or via your systems package manager. Once this is done it will work inside the virtualenv as well!

Leave a Reply

Your email address will not be published. Required fields are marked *