Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 2 years ago

#5012 closed defect (worksforme)

'module' object has no attribute 'connect'

Reported by: hall@… Owned by: Christopher Lenz
Priority: normal Milestone:
Component: web frontend/mod_python Version: 0.10.3.1
Severity: normal Keywords: mysql
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

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 (0)

Change History (10)

comment:1 by Emmanuel Blot, 15 years ago

Keywords: needinfo added

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

Have you installed some plugins?

comment:2 by Hall@…, 15 years ago

Version: 0.10.3.1

comment:3 by HallXE, 15 years ago

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

comment:4 by HallXE, 15 years ago

Plugins I have installed:

comment:5 by Christian Boos, 15 years ago

Component: generalmod_python frontend
Milestone: 0.10.5
Owner: changed from Jonas Borgström to Christopher Lenz

Can you try to add:

PythonInterpreter main_interpreter

in your <Location> section?

comment:6 by Christian Boos, 15 years ago

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:]

comment:7 by HallXE, 15 years ago

Resolution: fixed
Status: newclosed

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.

comment:8 by anonymous, 15 years ago

Keywords: needinfo removed
Milestone: 0.10.5
Resolution: fixed
Status: closedreopened

comment:9 by Christian Boos, 15 years ago

Keywords: mysql added
Resolution: worksforme
Status: reopenedclosed

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!

comment:10 by lefin17@…, 2 years ago

In my case there is chmod (access rights to installed module, there was only 0700) after I've fix it, I've get full functionality.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.