Ticket #5012 (closed defect: worksforme)
Opened 5 years ago
Last modified 5 years 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: | |||
| Release Notes: | |||
| API 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
Change History
comment:1 Changed 5 years ago by eblot
- Keywords needinfo added
comment:2 Changed 5 years ago by Hall@…
- Version set to 0.10.3.1
comment:3 Changed 5 years ago by HallXE
I'm using Trac 0.10.3.1, MySQL 5.0.27, python-2.3, MySQL_python-1.2.2.
comment:4 Changed 5 years ago by HallXE
Plugins I have installed:
- TracAccountManager? 0.1.3dev-r2063
- TracDiscussion? 0.5
- TracNav? 3.92
- TracNavHider? 1.0
- TracWebAdmin 0.1.2dev-r4429
comment:5 Changed 5 years ago by cboos
- Component changed from general to mod_python frontend
- Milestone set to 0.10.5
- Owner changed from jonas to cmlenz
Can you try to add:
PythonInterpreter main_interpreter
in your <Location> section?
comment:6 Changed 5 years 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:]
comment:7 Changed 5 years ago by HallXE
- Resolution set to fixed
- Status changed from new to closed
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 Changed 5 years ago by anonymous
- Keywords needinfo removed
- Milestone 0.10.5 deleted
- Resolution fixed deleted
- Status changed from closed to reopened
comment:9 Changed 5 years ago by cboos
- Keywords mysql added
- Resolution set to worksforme
- Status changed from reopened to closed
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!



Which version of Trac, which version of MySQLdb are you using?
Have you installed some plugins?