when cgi script runs before you puzzle over this too hardyou should know that this is often not concern in practice because python usually searches the current directory for imported modules by defaultthis is not an issue if all of your scripts and any modules and packages they use are stored in your web directoryand your web server launches cgi scripts in the directory in which they reside but if the module lives elsewhereyou may need to modify the sys path list in your scripts to adjust the search path manually before imports--for instancewith sys path append(dir namecallsindex assignmentsand so on end-of-line conventions (optionalon some unix (and linuxserversyou might also have to make sure that your script text files follow the unix end-of-line convention (\ )not dos (\ \nthis isn' an issue if you edit and debug right on the server (or on another unix machineor ftp files one by one in text mode but if you edit and upload your scripts from pc to unix server in tar file (or in ftp binary mode)you may need to convert end-of-lines after the upload for instancethe server that was used for the second edition of this text returns default error page for scripts whose end-of-lines are in dos format see for techniques and note on automated end-of-line converter scripts unbuffered output streams (optionalunder some serversthe print call statement may buffer its output if you have long-running cgi scriptto avoid making the user wait to see resultsyou may wish to manually flush your printed text (call sys stdout flush()or run your python scripts in unbuffered mode recall from that you can make streams unbuffered by running with the - command-line flag or by setting your pythonunbuffered environment variable to nonempty value to use - in the cgi worldtry using first line on unix-like platforms like #!usr/bin/python - in typical usageoutput buffering is not usually factor on some servers and clientsthoughthis may be resolution for empty reply pagesor premature end-of-script header errors--the client may time out before the buffered output stream is sent (though more commonlythese cases reflect genuine program errors in your scriptthis installation process may sound bit complex at first glancebut much of it is server-dependentand it' not bad once you've worked through it on your own it' only concern at install time and can usually be automated to some extent with python scripts run on the server to summarizemost python cgi scripts are text files of python codewhichare named according to your web server' conventions ( file pyare stored in directory recognized by your web server ( cgi-bin/are given executable file permissions if required ( chmod file py server-side scripting