Ticket #3488 (closed defect: invalid)
Opened 6 years ago
Last modified 4 years ago
initenv fails with confusing error message if sqlite not available
| Reported by: | ischenko@… | Owned by: | cboos |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | admin/console | Version: | 0.9.6 |
| Severity: | minor | Keywords: | sqlite initenv |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
Attempt to run 'initenv' command gives the following traceback:
Creating and Initializing Project
Failed to create environment. global name 'sqlite' is not defined
Traceback (most recent call last):
File "/home/tg/lib/python2.4/site-packages/trac-0.9.6-py2.4.egg/trac/scripts/admin.py", line 139, in env_create
self.__env = Environment(self.envname, create=True, db_str=db_str)
File "/home/tg/lib/python2.4/site-packages/trac-0.9.6-py2.4.egg/trac/env.py", line 79, in __init__
self.create(db_str)
File "/home/tg/lib/python2.4/site-packages/trac-0.9.6-py2.4.egg/trac/env.py", line 197, in create
db.init_db(self.path, db_str)
File "/home/tg/lib/python2.4/site-packages/trac-0.9.6-py2.4.egg/trac/db.py", line 442, in init_db
cls.init_db(**args)
File "/home/tg/lib/python2.4/site-packages/trac-0.9.6-py2.4.egg/trac/db.py", line 321, in init_db
cnx = sqlite.connect(path, timeout=int(params.get('timeout', 10000)))
NameError: global name 'sqlite' is not defined
Failed to initialize environment. 1
Traceback (most recent call last):
File "/home/tg/lib/python2.4/site-packages/trac-0.9.6-py2.4.egg/trac/scripts/admin.py", line 594, in do_initenv
self.env_create(db_str)
File "/home/tg/lib/python2.4/site-packages/trac-0.9.6-py2.4.egg/trac/scripts/admin.py", line 144, in env_create
sys.exit(1)
SystemExit: 1
Attachments
Change History
comment:1 Changed 6 years ago by ischenko@…
- Component changed from general to trac-admin
- Owner changed from jonas to daniel
- Severity changed from blocker to minor
- Summary changed from initenv fails with sqlite to initenv fails with confusing error message if sqlite not available
comment:2 follow-up: ↓ 3 Changed 6 years ago by nigel@…
I get an identical error but have sqlite installed by fink, that is sqlite not sqlite3. I wonder what else I need to do? Is there an sqlite driver required?
comment:3 in reply to: ↑ 2 Changed 6 years ago by mgood
Replying to nigel@nigelking.me.uk:
I get an identical error but have sqlite installed by fink, that is sqlite not sqlite3. I wonder what else I need to do? Is there an sqlite driver required?
You need to install pysqlite which is the Python binding to the SQLite library. The exectuable is not required and does not affect Trac.
comment:4 Changed 6 years ago by jayronc
i have pysqlite installed and i get the very same error.
comment:5 Changed 6 years ago by ffreitas@…
Me too.
I have pysqlite2 and sqlite 3.3.8 installed and when I init a envoirment, in TRAC 0.10, this error is show to me.
comment:6 follow-up: ↓ 8 Changed 6 years ago by brosner@…
I also had this problem. The reason for the problem is because Python is unable to find the libsqlite3.so. If you compiled SQLite yourself you need to make sure that you are using —prefix=/usr to get the libraries installed in the path of including them inside of Python. It appears the default location of where SQLite is installing (I am using version 3.3.8) is /usr/local which is not in the LD_LIBRARY_PATH.
I hope this helps somebody out there or it might just be more of my fix. Good luck!
comment:7 Changed 6 years ago by Christian Boos
- Milestone set to 0.10.1
- Owner changed from daniel to cboos
We can probably try to provide a better error message in the next release.
comment:8 in reply to: ↑ 6 Changed 6 years ago by anonymous
Replying to brosner@gmail.com:
I also had this problem. The reason for the problem is because Python is unable to find the libsqlite3.so. If you compiled SQLite yourself you need to make sure that you are using —prefix=/usr to get the libraries installed in the path of including them inside of Python. It appears the default location of where SQLite is installing (I am using version 3.3.8) is /usr/local which is not in the LD_LIBRARY_PATH.
I hope this helps somebody out there or it might just be more of my fix. Good luck!
I've got the error when tried to upgrade from 0.9.6 to 0.10. I've confirmed the LD_LIBRARY_PATH is set correctly and python is loading libsqlite3.so (>>> import pysqlite2.dbapi2 as sqlite successfully passes).
It seems to failing to build component registry at initialization, since trac.db.DatabaseManager?.connectors is empty array when DatabaseManager?._get_conector() called.
comment:9 follow-up: ↓ 10 Changed 5 years ago by anonymous
LD_LIBRARY_PATH doesn't work. But, sqllite with ./configure —prefix=/usr does.
comment:10 in reply to: ↑ 9 Changed 5 years ago by dt
Replying to anonymous:
LD_LIBRARY_PATH doesn't work. But, sqllite with ./configure —prefix=/usr does.
I'd like to confirm that your suggestion worked on mine to resolve the issue.
-dt
comment:11 Changed 5 years ago by yolus
Latest version of trac/sqlite/pysqlite. Same issue on RHEL ES4 U4. Tried fixes mentioned above, did not make any difference.
comment:12 Changed 5 years ago by cboos
- Milestone 0.10.4 deleted
- Resolution set to invalid
- Status changed from new to closed
This is an installation issue, and probably has little to do with Trac itself.
On the command-line, instead of running trac-admin, try first this:
$ python >>> from pysqlite2 import dbapi2 as sqlite >>> sqlite.version '2.3.3' >>> sqlite.sqlite_version '3.3.8'
The from ... import most probably won't succeed for you either, and this shows you have a SQLite/PySqlite2 installation issue (see PySqlite).
Also, I just noticed that in the original error report, Trac was packaged as an .egg file (trac-0.9.6-py2.4.egg). I'm not sure if this can be an explanation for the original problem, but using Trac in an .egg is not yet supported (it will be in 0.11).
Please feel free to reopen if the test import statement above succeeds.
comment:13 Changed 5 years ago by anonymous
- Resolution invalid deleted
- Status changed from closed to reopened
- Version changed from 0.9.6 to 0.10.3
I have this problem on WindowsXP SP2 with trac-0.10.3.win32 and sqlite3.
What I must doing?
comment:14 Changed 5 years ago by eblot
- Resolution set to invalid
- Status changed from reopened to closed
- Version changed from 0.10.3 to 0.9.6
For installation issue, please ask for support on the MailingList.
comment:15 follow-up: ↓ 16 Changed 5 years ago by falkg@…
- Milestone set to 0.11
- Resolution invalid deleted
- Status changed from closed to reopened
- Version changed from 0.9.6 to devel
same problem,
any solution worked
In python it opens the sqlite library very well if you do it manually.
Because I have no root rights on the machine I had to install the python + sqlite + pysqlite in my home directory.
It fails with the issue:
db = self.env.get_db_cnx()
File "/users3/gsimon/progs/lib/python2.4/site-packages/Trac-0.11dev_r6060-py2.4.egg/trac/env.py", line 239, in get_db_cnx
return DatabaseManager(self).get_connection()
File "/users3/gsimon/progs/lib/python2.4/site-packages/Trac-0.11dev_r6060-py2.4.egg/trac/db/api.py", line 76, in get_connection
return self._cnx_pool.get_cnx(self.timeout or None)
File "/users3/gsimon/progs/lib/python2.4/site-packages/Trac-0.11dev_r6060-py2.4.egg/trac/db/pool.py", line 101, in get_cnx
cnx = self._connector.get_connection(**self._kwargs)
File "/users3/gsimon/progs/lib/python2.4/site-packages/Trac-0.11dev_r6060-py2.4.egg/trac/db/sqlite_backend.py", line 121, in get_connection
self._version = get_pkginfo(sqlite).get(
NameError: global name 'sqlite' is not defined
comment:16 in reply to: ↑ 15 ; follow-up: ↓ 17 Changed 5 years ago by eblot
- Milestone 0.11 deleted
- Resolution set to invalid
- Status changed from reopened to closed
- Version changed from devel to 0.9.6
Replying to falkg@ensisun.imag.fr:
Because I have no root rights on the machine I had to install the python + sqlite + pysqlite in my home directory.
It fails with the issue:
This is an installation issue. Please read how to report any installation on the New Ticket page.
comment:17 in reply to: ↑ 16 Changed 5 years ago by eblot
Replying to eblot:
Please read how to report any installation issue on the New Ticket page., I meant
comment:18 Changed 5 years ago by anonymous
- Priority changed from normal to highest
- Resolution invalid deleted
- Severity changed from minor to blocker
- Status changed from closed to reopened
cboos is wrong, when i run his script on the commandline i get:
# python Python 2.3.6 (#1, Nov 1 2007, 16:31:52) [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from pysqlite2 import dbapi2 as sqlite >>> sqlite.version '2.3.5' >>> sqlite.sqlite_version '3.5.1' >>>
So the installation is correct.
However when i run trac-admin i still get this error:
Please enter location of Trac page templates.
Default is the location of the site-wide templates installed with Trac.
Templates directory [/usr/share/trac/templates]>
Creating and Initializing Project
Failed to create environment. global name 'sqlite' is not defined
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/trac/scripts/admin.py", line 613, in do_initenv
options=options)
File "/usr/lib/python2.3/site-packages/trac/env.py", line 145, in __init__
self.create(options)
File "/usr/lib/python2.3/site-packages/trac/env.py", line 250, in create
DatabaseManager(self).init_db()
File "/usr/lib/python2.3/site-packages/trac/db/api.py", line 70, in init_db
connector.init_db(**args)
File "/usr/lib/python2.3/site-packages/trac/db/sqlite_backend.py", line 121, in init_db
cnx = sqlite.connect(path, timeout=int(params.get('timeout', 10000)))
NameError: global name 'sqlite' is not defined
Failed to initialize environment. 1
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/trac/scripts/admin.py", line 617, in do_initenv
sys.exit(1)
SystemExit: 1
I have searched the internet for solutions:
http://trac.edgewall.org/wiki/TracOnFedoraCoreThree
http://groups.google.com/group/trac-users/browse_thread/thread/61b283dd3757af13/b5a03a5b5465d448?lnk=gst&q=global+name+%27sqlite%27+is+not+defined#b5a03a5b5465d448
http://lists.initd.org/pipermail/pysqlite/2006-March/000446.html
http://lists.edgewall.com/archive/trac/2005-October/005150.html
But none work,
this is clearly a bug in trac.. at least from a user perspective point of view.
comment:19 Changed 5 years ago by anonymous
- Priority changed from highest to normal
- Resolution set to invalid
- Severity changed from blocker to minor
- Status changed from reopened to closed
sorry i had to restart my bashshell for the fix to have effect,
strange
comment:20 Changed 4 years ago by emx
I had the same problem. In my case it turned out that I had two different version of Python installed (2.4 for compatibility for FC5 yum, and 2.5 for the new TRAC).
I downloaded sqlite and python-sqlite and built them from source. It installed them properly under the python 2.5 dirs.
After that, all worked fine (for me). YMMV.



It happens because sqlite is not available but it surely can yield more human-friendly message.