Search code examples
pythonweb-servicesmod-pythonimdb

import python module when using mod_python


i have been using imdbpy for some time. I was interested in making a very basic webservice to return json data.

I have a basic system working earlier today however after a reboot i now get the following error AssertionError: Import cycle in /home/prog/www/imdb/imdb.py.

the code is being ran using mod_python. which 100% works. the following lines seem to be the problem

#!/usr/bin/env python
import imdb
from mod_python import apache

def handler(req):
        req.content_type = "text/plain"
        req.write("test")
        return apache.OK

if i comment the import imdb test is printed.

Any help would be great


Solution

  • I guess this could be the problem: You named your file "imdb.py". Rename it and the problem could be solved.

    Explication: When importing imdb, python finds your module before finding the imdb-package that you initially wanted to import (because current folder is listed in PYTHONPATH before the the standard python library). So basically you import yourself.