Python on Dreamhost

In my previous post I described how I kind of got TurboGears running on Dreamhost. The problem was that it died after a few seconds. Crawling the wiki and other sources, it seems like there is a process that will kill the Python process, unless it happens to be named dispatch.fcgi. So I scrapped that plan (rm -fr my.domain.name) and decided to start again.

Looking at the Python FastCGI page I first easy_installed Flup (as described at the end of the page), created .htaccess file to redirected everything to dispatch.fcgi like instructed on that page, and made the dispatch.fcgi like in the Flup section of that page, chmod 755 dispatch.fcgi, waited a little, and tried browsing to my site. After a long time, it finally returned server error. Not good. But since there is so little code now, it is easy to debug. I put just a little exception handler around the whole script, and made it write to a log file any exceptions. And sure enough, there was error! Now we were getting somewhere. The error was about being unable to import flup. Hmm, so it looks like my Python environment wasn’t working through FastCGI as I expected.

So I did an alternative approach by using fcgi.py (wget http://svn.saddi.com/py-lib/trunk/fcgi.py into my.domain.name). Then I edited the dispatch.fcgi to match the dispatch.fcgi like in the beginning of the Python FastCGI wiki page on Dreamhost. Waited a while. Browsed to my site. Waiting, waiting, waiting…. IT WORKED!

So, I think I’ll either do my own Python 2.5 installation or virtual Python setup. Both approaches are described on the Python on Dreamhost wiki page.

I think I am also going to forget TurboGears and move to Pylons, since it seems Pylons is the future.

Update: See my Pylons on Dreamhost post for the final details.

Similar Posts:

    None Found