I used Django 1.3.1, Python 2.7.1, virtualenv 1.6.4 and virtualenvwrapper 2.10.1 for the scenario described in this post.
After I’d deployed my first Django site that used virtualenv, I attempted to run sudo ./manage.py shell
on the server to inspect some data on my site, but I got an error that django.core.management
couldn’t be found. I figured I hadn’t set some path properly when I saw the error, but I was a little puzzled as to which, since my site worked perfectly in the browser, but failed to run Django management commands. I opened my project’s manage.py, and noticed the interpreter directive was just pointing at the system’s python
. Since I was using virtualenv, I simply changed the Python in my manage.py to point at the one in my virtualenv and management commands worked awesomely again. See below:
Replace the first line with in manage.py with:
#!/usr/bin/env your-virtualenv-dir/your-virtual-env/bin/python