Edgewall Software

Ticket #5012 (closed defect: worksforme)

Opened 22 months ago

Last modified 22 months ago

'module' object has no attribute 'connect'

Reported by: hall@… Owned by: cmlenz
Priority: normal Milestone:
Component: web frontend/mod_python Version: 0.10.3.1
Severity: normal Keywords: mysql
Cc:

Description

When this error happens, I would leave my Trac site Idle for a while.

Later, my Trac site is suddenly back to normal. Then, I start working with Trac, post some Tickets, add some Wiki. Then, this error starts to show up again.

So guess what I did, yup, I leave my Trac site Idle for a while. So it goes in a loop.

Please help!!

Traceback (most recent call last):

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

  File "/usr/lib/python2.3/site-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.3/site-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

  File "/usr/lib/python2.3/site-packages/trac/web/modpython_frontend.py", line 87, in handler
    gateway.run(dispatch_request)

  File "/usr/lib/python2.3/site-packages/trac/web/wsgi.py", line 87, in run
    response = application(self.environ, self._start_response)

  File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 377, in dispatch_request
    env = _open_environment(env_path, run_once=run_once)

  File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 58, in _open_environment
    env_cache[env_path] = open_environment(env_path)

  File "/usr/lib/python2.3/site-packages/trac/env.py", line 435, in open_environment
    if env.needs_upgrade():

  File "/usr/lib/python2.3/site-packages/trac/env.py", line 313, in needs_upgrade
    db = self.get_db_cnx()

  File "/usr/lib/python2.3/site-packages/trac/env.py", line 182, in get_db_cnx
    return DatabaseManager(self).get_connection()

  File "/usr/lib/python2.3/site-packages/trac/db/api.py", line 75, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)

  File "/usr/lib/python2.3/site-packages/trac/db/pool.py", line 101, in get_cnx
    cnx = self._connector.get_connection(**self._kwargs)

  File "/usr/lib/python2.3/site-packages/trac/db/mysql_backend.py", line 40, in get_connection
    return MySQLConnection(path, user, password, host, port, params)

  File "/usr/lib/python2.3/site-packages/trac/db/mysql_backend.py", line 139, in __init__
    cnx = MySQLdb.connect(db=path, user=user, passwd=password,

AttributeError: 'module' object has no attribute 'connect'

Attachments

Change History

Changed 22 months ago by eblot

  • keywords needinfo added

Which version of Trac, which version of MySQLdb are you using?

Have you installed some plugins?

Changed 22 months ago by Hall@…

  • version set to 0.10.3.1

Changed 22 months ago by HallXE

I'm using Trac 0.10.3.1, MySQL 5.0.27, python-2.3, MySQL_python-1.2.2.

Changed 22 months ago by HallXE

Plugins I have installed:

Changed 22 months ago by cboos

  • owner changed from jonas to cmlenz
  • component changed from general to mod_python frontend
  • milestone set to 0.10.5

Can you try to add:

PythonInterpreter main_interpreter

in your <Location> section?

Changed 22 months ago by cboos

Also, what mod_python version are you using? Do you also have PHP active in that setup? (see possibly related #4459)

In order to sort out what's happening, can you make the following changes?

Index: trac/db/mysql_backend.py
===================================================================
--- trac/db/mysql_backend.py	(revision 5135)
+++ trac/db/mysql_backend.py	(working copy)
@@ -145,6 +145,9 @@
     def __init__(self, path, user=None, password=None, host=None,
                  port=None, params={}):
         import MySQLdb
+        print `MySQLdb`
+        from pprint import pprint        
+        pprint(MySQLdb.__dict__)
 
         if path.startswith('/'):
             path = path[1:]

Changed 22 months ago by HallXE

  • status changed from new to closed
  • resolution set to fixed

Your suggestion PythonInterpreter main_interpreter reminded me I probably have multiple versions of python laying around because previously I did a yum install on python & mysql-python and didn't find it quite right. So I recompiled them from source but didn't remove the old one.

I might be wrong but my guess is Trac was randomly using either one of the interpreter, that's why this happens once in a while.

Thanks a lot for the input cboos though I didn't follow your suggestions. I just removed all python & mysql-python and recompiled them.

My Trac is site is working fine now.

Changed 22 months ago by anonymous

  • keywords needinfo removed
  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone 0.10.5 deleted

Changed 22 months ago by cboos

  • keywords mysql added
  • status changed from reopened to closed
  • resolution set to worksforme

Ok, I'm glad it works for you now. However we missed the opportunity to know a little more about this kind of strange error messages. If someone else experiences this in the future, please follow-up on #4459 instead of reopen this ticket, thanks!

Add/Change #5012 ('module' object has no attribute 'connect')

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cmlenz. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.