Edgewall Software
Modify

Opened 18 years ago

Closed 17 years ago

Last modified 16 years ago

#3488 closed defect (invalid)

initenv fails with confusing error message if sqlite not available

Reported by: ischenko@… 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 ischenko@…, 18 years ago

Component: generaltrac-admin
Owner: changed from Jonas Borgström to daniel
Severity: blockerminor
Summary: initenv fails with sqliteinitenv fails with confusing error message if sqlite not available

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

comment:2 by nigel@…, 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?

in reply to:  2 comment:3 by Matthew Good, 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:4 by jayronc, 18 years ago

i have pysqlite installed and i get the very same error.

comment:5 by ffreitas@…, 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.

comment:6 by brosner@…, 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 Christian Boos, 18 years ago

Milestone: 0.10.1
Owner: changed from daniel to Christian Boos

We can probably try to provide a better error message in the next release.

in reply to:  6 comment:8 by anonymous, 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.

comment:9 by anonymous, 18 years ago

LD_LIBRARY_PATH doesn't work. But, sqllite with ./configure —prefix=/usr does.

in reply to:  9 comment:10 by dt, 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 yolus, 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 Christian Boos, 18 years ago

Milestone: 0.10.4
Resolution: invalid
Status: newclosed

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 anonymous, 18 years ago

Resolution: invalid
Status: closedreopened
Version: 0.9.60.10.3

I have this problem on WindowsXP SP2 with trac-0.10.3.win32 and sqlite3. What I must doing?

comment:14 by Emmanuel Blot, 18 years ago

Resolution: invalid
Status: reopenedclosed
Version: 0.10.30.9.6

For installation issue, please ask for support on the MailingList.

comment:15 by falkg@…, 17 years ago

Milestone: 0.11
Resolution: invalid
Status: closedreopened
Version: 0.9.6devel

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

in reply to:  15 ; comment:16 by Emmanuel Blot, 17 years ago

Milestone: 0.11
Resolution: invalid
Status: reopenedclosed
Version: devel0.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.

in reply to:  16 comment:17 by Emmanuel Blot, 17 years ago

Replying to eblot:

Please read how to report any installation issue on the New Ticket page., I meant

comment:18 by anonymous, 17 years ago

Priority: normalhighest
Resolution: invalid
Severity: minorblocker
Status: closedreopened

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 anonymous, 17 years ago

Priority: highestnormal
Resolution: invalid
Severity: blockerminor
Status: reopenedclosed

sorry i had to restart my bashshell for the fix to have effect, strange

comment:20 by emx, 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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.