In agreement to this question, and its answer. I added the path of the egg and it worked. However, when I run python interactively and I import flup, it works without any problem or additional path specification. Where is the difference ?
Edit: It appears that while doing fastcgi stuff, the .pth files are not parsed, but this is only a guess. Need more official statement.
After some more thorough analysis, I think I understand what's going on here.
When Python starts up, it sets up the sys.path (all as part of initializing the interpreter).
At this time, the environment is used to determine where to find .pth files. If no PYTHONPATH is defined at this time, then it won't find your modules installed to sys.prefix. Additionally, since easy-install.pth is probably installed to your custom prefix directory, it won't find that .pth file to be parsed.
Adding environment variables to os.environ or sys.path after the interpreter has initialized won't cause .pth files to be parsed again. This is why you're finding yourself forced to manually do what you expect Python to do naturally.
I think the correct solution is to make sure the custom path is available to the Python interpreter at the time the interpreter starts up (which is before mysite.fcgi is executed).
I looked for options to add a PYTHONPATH environment variable to mod_fastcgi, but I see no such option. Perhaps it's a general Apache option, so not documented in mod_fastcgi, or perhaps it's not possible to set a static variable in the mod_fastcgi config.
Given that, I believe you could produce a workaround with the following:
Although I don't have a good environment in which to test, I think a wrapper shell script would look something like:
#!/bin/sh
export PYTHONPATH=/your/local/python/path
/path/to/python /path/to/your/fastcgi/handler # this line should be similar to what was supplied to mod_fastcgi originally
There may be alternative workarounds to consider.