I've been through the Webfaction 'Getting Started with Django' instructions which were very clear and make sense.
However, I have an existing Django project I wish to use, and I'd like to run it within a virtualenv and I'm not sure how to amend those instructions for running the server within a virtualenv. I have virtualenv running OK on the command line, but hit problems when trying to access my Django site.
I've read these instructions which helped me get this far (using a standard Django app, as per the above instructions, rather than a mod_wsgi one), but Django seems confused about project and app names, and I'm stuck.
Does anyone have simple instructions, to continue from Webfaction's Django instructions, about using virtualenv?
Virtualenv has experienced some changes since this question was originally written. Also, some people like to remove the packages in
Now that virtualenv and virtualenvwrapper are installed, you can create, activate, deactivate, and remove environments:
This virtualenv will not use the global site packages in
However, because of the global
In some cases this is what you want and is convenient. Other times, you do not want a particular virtualenv to use your home-installed packages. If that's the case, then create an empty
and then this virtualenv ("
Oh, thanks David. I found a couple of crucial wsgi configuration lines in there that eventually got my site working! For future visitors, below is a summary of everything I've done to get things working. If anyone has any suggestions about things to improve, do let me know, as I've only worked this out by trial and error. This assumes you've probably used pip and virtualenv/virtualenvwrapper before and just want to get it working on WebFaction.
Follow the 'Getting Started with Django' instructions for setting up a Django site. This will have created:
Add these lines at the end of .bashrc:
Obviously, with a meaningful name instead of 'my_env_name'. Now we're working within that virtual environment.
Install any things you need. eg:
Or install from a pip requirements file from an existing project:
Then edit ~/webapps/django_application/myproject.wsgi. I don't know if all of these are required, but it seems to work for me...
Obviously, replace 'username', 'my_env_name', 'django_application' and 'myproject' as appropriate.
You'll need to do that last line every time you make a change to myproject.wsgi.
answered Jun 27 '11 at 12:38
I'm trying to learn along with you guys and when I add the paths to my .bashrc and sourced it I get this error.
Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named virtualenvwrapper.hook_loader virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7 and that PATH is set properly.
answered Jan 27 '12 at 20:41