added pyquery import in try catch blocks