Django not finding apps in virtualenv when using syncdb

My problem is in getting syncdb to run within a virtualenv.

It was working fine at one point, but seems to have broken sometime around when I installed South and updated pip and distribute.

Anyways, when the virtualenv is activated, I can import apps fine within the interactive interpreter. Running through mod_wsgi, the apps are imported as well, and the site can run.

When I run syncdb, it fails to find any app in INSTALLED_APPS that is in my virtualenv. It picks up system-installed apps fine, but fails when it tries to import virtualenv only apps.


Hi This is an old question, but saw its not answered. Not sure what you are attempting to do, but there are basically two modes you can use virtualenv,

  1. For development, to create self-contained environments
  2. For deployment, to create self-contained environments

In the first case, you need to first Activate your virtualenv with source venv/bin/activate, for when you deploy, you need to ensure that the virtualenv is activated for your website code. Personally i prefer the following approach to ensuring your path is set correctly. (I also add this to my when doing development, so i dont have to worry about activating the environment first.


#!/usr/bin/env python
import os.path

# Cater for Virtual env, add to sys.path
pwd = os.path.abspath(os.path.dirname(__file__))
project = os.path.basename(pwd)
new_path = pwd.strip(project)
activate_this = os.path.join(new_path,'venv','bin','')
execfile(activate_this, dict(__file__=activate_this))

from import execute_manager
    import settings # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file '' in the directory containing %r. It appears you've customized things.\nYou'll have to run, passing it your settings module.\n(If the file does indeed exist, it's causing an ImportError somehow.)\n" % __file__)

if __name__ == "__main__":

This works, due to how i structure my projects, you would have to change it to your directory structure. My projects are structured like so:

|- Project DIR
|- venv
|- requirements 
|- deployment configs

I have a simple solution to this

Just launch from the python in the bin of your virtual environment.

So say your python is here /home/tom/environments/my_env/bin/python you could launch like so:

/home/tom/environments/my_env/bin/python syncdb

then just create a symlink to the virtual environment's python inside your django project and call it env_python then you can do this:

./env_python syncdb

Need Your Help

d3.js Slider: how to get value?

javascript d3.js slider

Ok all, so I know this has been asked before, but I've been having trouble figuring it out from the examples I've seen. I have a d3 slider with a range of years. I'm trying to get it to console