Skip to content

Instantly share code, notes, and snippets.

@nferrari
Created May 17, 2015 08:07
Show Gist options
  • Save nferrari/00938d0c6180351848da to your computer and use it in GitHub Desktop.
Save nferrari/00938d0c6180351848da to your computer and use it in GitHub Desktop.
Python 2.7 + Django 1.8 on alwaysdata
Create our environment directory
$ mkdir .local
Create a temporary directory
$ mkdir tmp
Install Python 2.7
$ cd tmp
$ wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
$ tar zxvf Python-2.7.9.tgz
$ cd Python-2.7.9
$ ./configure --prefix=$HOME/.local
$ make
$ make install
Change default Python version (to write in $HOME/.bash_profile)
$ export PYTHONPATH=$HOME/.local
$ export PATH=$PYTHONPATH:$PYTHONPATH/bin:$PATH
Install pip for Python 2.7
$ cd $HOME/tmp
$ wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
Install some Python modules
$ pip install virtualenv virtualenvwrapper
Initialize virtualenvs (to write in $HOME/.bash_profile)
$ export WORKON_HOME=$HOME/.virtualenvs
$ mkdir -p $WORKON_HOME
$ source $PYTHONPATH/bin/virtualenvwrapper.sh
Create first virtualenv
$ mkvirtualenv myprojectenv
Install Django
$ pip install django==1.8.1
@nferrari
Copy link
Author

Python 2.7 choice: Django may be Python 3 compatible but as a FastCGI application, it requires flup which is not yet compatible Python 3.

Don't forget to write lines 17, 18, 29, 30 and 31 in your $HOME/.bash_profile file (create it if it does not exist).

When creating your django.fcgi file (as explained on alwaysdata documentation page), replace the first lines by:

#!/usr/bin/eval PYTHON_VERSION=2.7 DJANGO_VERSION=1.8.1 python
import os, site, sys

site.addsitedir("/home/xxxxxxx/.virtualenvs/myprojectenv/lib/python2.7/site-packages/")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment