Your web server is running under a different user or something, so it gets a different PATH than your command line. That's making it run Python 1.5 which doesn't support +=. Change /usr/bin/env python to wherever your Python 2.x executable is, e.g. /usr/local/bin/python.