I realize this is ancient code, but hoped this report might still be useful. Ubuntu now mixes sqlalchemy 0.7 with turbogears 1.1.1. Thesqlalchemy.exceptions module is now sqlalchemy.exc.
The import error was masked by the old logic making this more difficult than necessary to resolve. I changed the import logic in database.py to be:
try:
import sqlalchemy
except ImportError:
sqlalchemy = None
else:
import sqlalchemy.orm
from sqlalchemy import MetaData
try:
from sqlalchemy.exc import ArgumentError, OperationalError
except ImportError:
try:
from sqlalchemy.orm.exc import ArgumentError, OperationalError
except ImportError: # SQLAlchemy < 0.5
from sqlalchemy.exceptions import ArgumentError, OperationalError
try:
import sqlobject
except ImportError:
sqlobject = None
else:
from sqlobject.dbconnection import ConnectionHub, Transaction, TheURIOpener
from sqlobject.util.threadinglocal import local as threading_local
This works for me. It will raise ImportError if one of the subsequent imports does not work, while still properly catching the absence of sqlalchemy and sqlobject. It minimizes the number of statements where the errors are suppressed.