Question: I have installed Python and configured in apache. I created a Python web file and open this in browser, I get an error. But the same code working in command-line. I hope the problem is from my apache configuration. 

This is the error message.

```
MOD_PYTHON ERROR

ProcessId:      6368
Interpreter:    'localhost'

ServerName:     'localhost'
DocumentRoot:   '/var/www'

URI:            '/python_test/hello_world.py'
Location:       None
Directory:      '/var/www/'
Filename:       '/var/www/python_test/hello_world.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'mod_python.py'

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1202, in _process_target
    module = import_module(module_name, path=path)

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 304, in import_module
    return __import__(module_name, {}, {}, ['*'])

ImportError: No module named py

```

My Python code is :

```
print "Hello world!"

My httpd.conf file is :

ServerName localhost
<Directory /var/www/>
        Options Indexes FollowSymlinks MultiViews
        AllowOverride AuthConfig
        order allow,deny
        allow from all

        AddHandler mod_python .py
        PythonHandler mod_python.py
        PythonDebug On

</Directory>

```

Answer: 
[AddHandler](http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler) requires additional parameters and you basically provide it with the python extension `.py`. Then you provide the name of the Python file to the [PythonHandler](http://www.modpython.org/live/current/doc-html/dir-handlers-ph.html) without the extension.

```
AddHandler cgi-script .py
PythonHandler mod_python
PythonDebug On

```
There appears to be a typo in your httpd.conf `AddHandler mod_python .py`

Because of the space it is looking for two modules `mod_python` and `py`