My guess is that CGI uses the system python. Not the python that has the Asterisk module.
Check that the failing CGI script does not have
#!/usr/bin/python
And if does, change this to use the proper Python.
For each python you have try doing:
from asterisk import agitb
Then you will find which one has asterisk