#3488 closed defect (invalid)
initenv fails with confusing error message if sqlite not available
Reported by: | Owned by: | Christian Boos | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | admin/console | Version: | 0.9.6 |
Severity: | minor | Keywords: | sqlite initenv |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal 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 (0)
Change History (20)
comment:1 by , 18 years ago
Component: | general → trac-admin |
---|---|
Owner: | changed from | to
Severity: | blocker → minor |
Summary: | initenv fails with sqlite → initenv fails with confusing error message if sqlite not available |
follow-up: 3 comment:2 by , 18 years ago
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 by , 18 years ago
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:5 by , 18 years ago
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.
follow-up: 8 comment:6 by , 18 years ago
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 by , 18 years ago
Milestone: | → 0.10.1 |
---|---|
Owner: | changed from | to
We can probably try to provide a better error message in the next release.
comment:8 by , 18 years ago
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.
follow-up: 10 comment:9 by , 18 years ago
LD_LIBRARY_PATH doesn't work. But, sqllite with ./configure —prefix=/usr does.
comment:10 by , 18 years ago
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 by , 18 years ago
Latest version of trac/sqlite/pysqlite. Same issue on RHEL ES4 U4. Tried fixes mentioned above, did not make any difference.
comment:12 by , 18 years ago
Milestone: | 0.10.4 |
---|---|
Resolution: | → invalid |
Status: | new → 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 by , 18 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Version: | 0.9.6 → 0.10.3 |
I have this problem on WindowsXP SP2 with trac-0.10.3.win32 and sqlite3. What I must doing?
comment:14 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
Version: | 0.10.3 → 0.9.6 |
For installation issue, please ask for support on the MailingList.
follow-up: 16 comment:15 by , 17 years ago
Milestone: | → 0.11 |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
Version: | 0.9.6 → 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
follow-up: 17 comment:16 by , 17 years ago
Milestone: | 0.11 |
---|---|
Resolution: | → invalid |
Status: | reopened → closed |
Version: | devel → 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 by , 17 years ago
Replying to eblot:
Please read how to report any installation issue on the New Ticket page., I meant
comment:18 by , 17 years ago
Priority: | normal → highest |
---|---|
Resolution: | invalid |
Severity: | minor → blocker |
Status: | closed → 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 by , 17 years ago
Priority: | highest → normal |
---|---|
Resolution: | → invalid |
Severity: | blocker → minor |
Status: | reopened → closed |
sorry i had to restart my bashshell for the fix to have effect, strange
comment:20 by , 16 years ago
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.