我的环境:
Debian: 9.3
trac/stable,now 1.2+dfsg-1 all [installed]
python-mysqldb/stable,now 1.3.7-1.1 amd64 [installed]
我遵循trac
手动,执行trac-admin /usr/share/trac initenv
并获取此跟踪:
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"
我认为该错误是由于/usr/lib/python2.7/dist-packages/trac/db/mysql_backend.py
没有被导入(甚至MySQLConnector.get_supported_schemes()
没有被执行)。问题是我在代码中找不到任何引用来加载此文件。我只能找到界面IDatabaseConnector
。
postgres 后端/usr/lib/python2.7/dist-packages/trac/db/postgres_backend.py
也不会加载,但是一旦我安装python-psycopg2
它,它就会神奇地开始加载。为何如此?
有人可以解释一下这里的 python 魔力以及如何让mysql
后端工作吗?
答案1
最简单的解决方法是在安装后编辑 /usr/lib/python2.7/dist-packages/Trac-1.2.egg-info/entry_points.txt 并从中删除 [mysql] 后缀: trac.db.mysql = trac.db .mysql_backend[mysql]
答案2
我最近升级到 Ubuntu 18.04,调试后发现 python-pymysql 包以某种方式被自动删除(升级实际上有一些损坏的依赖问题,必须手动解决)。后
$ apt install python-pymysql
trac 又开始工作了。
答案3
遇到同样的问题后,以下方法有效。
$ pip install MySQL-python
当然,这是使用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