I come from a PHP background so I'm used to everything being in one place. I want to install a python program (Zine)so that I can hack on it. The instructions I've found install it to the system in multiple folders. I do not want to edit files that are installed in Linux system directories.

What is the python way to layout the directory on the filesystem for a web program that under active development?

would it be:





  • Take a look at virtualenv. If you want/need to experiment with packages that should replace your system packages, you can easily create a sandbox to experiment and/or reproduce your deployment environment.
    – 9000
    Jul 3, 2011 at 17:44
  • What do you use to run Python code? It's typical nowadays to run a Python-based web server that runs your code and hide it behind a 'normal' web server, usually via FastCGI. This way, you don't even need to give the webserver account any access to your code/data, since your Python server runs under a different user. Or do you use mod_python?
    – 9000
    Jul 3, 2011 at 17:50
  • I will be using mod_wsgi. I want to create a self contained python app (including htdocs) so I can keep it versioned in git, which also helps with deployment across my live, test and dev servers. Jul 3, 2011 at 19:03

1 Answer 1


Python uses directories to form packages of modules. You then import the module (or what you need from a module) so it can be used in the file you are currently working in.

If the file's path is sound\effects\echo.py, you would import it like this:

import sound.effects.echo
  • So just put everything in my web root and import from there? htdocs/python/package Jul 3, 2011 at 13:41
  • 1
    They just need to be somewhere that Python can find it. Module Search Path. Jul 3, 2011 at 14:36
  • 1
    Don't put your packages to htdocs/ unless you want everyone to observe your source code (or, worse, configs and data files). Put the code somewhere where your server can access it and put that dir on PYTHONPATH of your Python interpreter.
    – 9000
    Jul 3, 2011 at 17:46
  • Sounds like there is no best practice for file location with web applications. Jul 3, 2011 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.