How to install Django using virtualenv

Using virtualenv to install Django is recommended. This is because when you use virtualenv, you create an isolated environment with its own installation directories. This allows you to install a custom version of Python and its different packages which is not connected to the global installation on the server. This also solves the issue with permissions when installing software.

pip and virtualenv

pip and virtualenv are already installed on DreamHost servers by default. You'll use these to install Django.

Installing a custom version of Python for your virtualenv

If you're planning on using Django with a new virtual environment, chances are you want to use a specific version of Python. Review the following article to install a custom version of Python and create a virtual environment using this custom version:

Create a virtual environment

View the following article to create a virtual environment:

After you've created and activated a project in a virtual environment, you can then install Django within this isolated environment.

Setting up your Django site in virtualenv

To run the commands in this article, you must log into your server via SSH with your Shell user. View the following articles for more information:

Install a custom version of Django and any other required packages (e.g., MySQL-Python if you're going to use a MySQL database with Python 2.7) for your website using pip:

(my_project) [server]$ pip install Django
(my_project) [server]$ pip install MySQL-python

See also

Did this article answer your questions?

Article last updated .