2

My environment:

Debian: 9.3
trac/stable,now 1.2+dfsg-1 all [installed]
python-mysqldb/stable,now 1.3.7-1.1 amd64 [installed]

I follow the trac manual, execute trac-admin /usr/share/trac initenv and get this trace:

Creating and Initializing Project
Initenv for '/usr/share/trac' failed. 
Failed to create environment.
Unsupported database type "mysql"
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/trac/admin/console.py", line 497, in do_initenv
    options=options)
  File "/usr/lib/python2.7/dist-packages/trac/core.py", line 128, in __call__
    self.__init__(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/trac/env.py", line 299, in __init__
    self.create(options)
  File "/usr/lib/python2.7/dist-packages/trac/env.py", line 591, in create
    DatabaseManager(self).init_db()
  File "/usr/lib/python2.7/dist-packages/trac/db/api.py", line 337, in init_db
    connector, args = self.get_connector()
  File "/usr/lib/python2.7/dist-packages/trac/db/api.py", line 606, in get_connector
    scheme=scheme))
TracError: Unsupported database type "mysql"

I figured that the error is due to /usr/lib/python2.7/dist-packages/trac/db/mysql_backend.py not being imported (and MySQLConnector.get_supported_schemes() doesn't even get executed). Problem is that I can not find any reference in the code for it to load this file. I can only find the interface IDatabaseConnector.

The postgres backend /usr/lib/python2.7/dist-packages/trac/db/postgres_backend.py doesn't load either, but once I install python-psycopg2 it magically starts to load. How so?

Can someone explain the python magic at work here and how I can get the mysql backend to work?

  • Naive question: what was the command to enable trace in initenv? – John Smith Jul 14 '19 at 21:43
1

The easiest workaround is to edit /usr/lib/python2.7/dist-packages/Trac-1.2.egg-info/entry_points.txt after install and remove the [mysql] suffix from: trac.db.mysql = trac.db.mysql_backend[mysql]

| improve this answer | |
  • It would be cool if there were some explanation for why this worked. – Jubjub Bandersnatch Dec 26 '19 at 14:37
1

I recently upgraded to Ubuntu 18.04 and found after debugging that the package python-pymysql was somehow autoremoved (the upgrade actually had some broken dependency problems that had to be solved manually). After

$ apt install python-pymysql

trac was working again.

| improve this answer | |
0

After experiencing this same issue, the following worked.

$ pip install MySQL-python

Of course, this is using a virutalenv.

cd /home/user/dev
mkdir TracEnv
mkdir TracEnv/TracProject
cd ./TracEnv/
virtualenv venv
source ./venv/bin/activate
pip install trac
pip install MySQL-python
trac-admin /home/user/dev/TracEnv/TracProject initenv
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.