views:

407

answers:

2

I tried to install pysqlite. Some suspicious things start to appear during the installation. Why I typed:

python setup.py build

I got the following message in the end:

src/module.c:286: error: ‘SQLITE_PRAGMA’ undeclared here (not in a function)
src/module.c:287: error: ‘SQLITE_READ’ undeclared here (not in a function)
src/module.c:288: error: ‘SQLITE_SELECT’ undeclared here (not in a function)
src/module.c:289: error: ‘SQLITE_TRANSACTION’ undeclared here (not in a function)
src/module.c:290: error: ‘SQLITE_UPDATE’ undeclared here (not in a function)
src/module.c:291: error: ‘SQLITE_ATTACH’ undeclared here (not in a function)
src/module.c:292: error: ‘SQLITE_DETACH’ undeclared here (not in a function)
src/module.c: In function ‘init_sqlite’:
src/module.c:419: warning: implicit declaration of function ‘sqlite3_libversion’
src/module.c:419: warning: passing argument 1 of ‘PyString_FromString’ makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1

I just ignored the last line and decided to continue. So, I typed:

python setup.py install

And than, again, I got similar error message:

src/module.c:288: error: ‘SQLITE_SELECT’ undeclared here (not in a function)
src/module.c:289: error: ‘SQLITE_TRANSACTION’ undeclared here (not in a function)
src/module.c:290: error: ‘SQLITE_UPDATE’ undeclared here (not in a function)
src/module.c:291: error: ‘SQLITE_ATTACH’ undeclared here (not in a function)
src/module.c:292: error: ‘SQLITE_DETACH’ undeclared here (not in a function)
src/module.c: In function ‘init_sqlite’:
src/module.c:419: warning: implicit declaration of function ‘sqlite3_libversion’
src/module.c:419: warning: passing argument 1 of ‘PyString_FromString’ makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1

After that I wanted to try if pysqlite works. If in the python-command-line mode I type

from pysqlite2 import *

Python does not complain. However, if I try to follow an exmaple in my book:

from pysqlite2 import dbapi2 as sqlite

I get a error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pysqlite2/dbapi2.py", line 27, in <module>
    from pysqlite2._sqlite import *
ImportError: No module named _sqlite

Does anybody have any ideas why it happens and how this problem can be solved. By the way, I have installed a new version of Python. "python -V" gives me "Python 2.6.2". Thank you in advance for any help.

+3  A: 

I just ignored the last line and decided to continue.

You can't just ignore the last line. It was telling you there was an error, so it couldn't compile. The next thing you ran told you it couldn't install because it couldn't compile. Then, your python told you it couldn't run the code because it wasn't installed. You need to get the compile step working before you move on to installing it.

RHSeeger
OK. But how to compile and install? What the error message means?
Verrtex
Unfortunately, I likely cannot help you with getting it to compile. The best I could do was point out that it was the compilation phase that was failing and anything past that was not useful in resolving the issue.
RHSeeger
+1  A: 

A lesson in compiling python extensions is needed, which distribution are you using ? You seem to be missing the sqlite headers with the given macro definitions. When the python setup runs it compiles bindings to the sqlite native binary and copies a few .py files to the library. The _sqlite is typically a .pyd file (equivalent to a dll) which has calls to the sqlite library, in your case that did not get built.

Check the presence of the sqlite headers etc.

whatnick