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 ("
This answer is marked "community wiki".
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 27 Jun '11, 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 27 Jan '12, 20:41
In the accepted answer, I think:
should instead be
answered 08 Jun '14, 02:44
I had some troubles figuring out how to deploy a Python 3.4 & Django 1.8 app in Webfaction using virtual environment (Python 3.4 venv).
Basically the answer is to create the application in Webfaction control site as a mod_wsgi application, set up Django and virtual environment manually over SSH and modify slightly the default Apache httpd.conf. I posted my notes on my blog: http://www.mikkohaapanen.com/deploying-django-app-in-webfaction-with-virtual-environment/
answered 08 Nov '15, 09:59