views:

398

answers:

2

I have installed Python 2.6.2.. I did it "locally" since I do not have root permissions. With this version of Python I wanted to use module called "sqlite3" (it is called "pysqlite" in earlier versions). In theory I had to be able to use this module without any problems since it is supposed to be included by default in the considered version of Python. However, I have some troubles. When I type:

from sqlite3 import *

I get:

Traceback (most recent call last): File "", line 1, in File "/home/verrtex/opt/lib/python2.6/sqlite3/init.py", line 24, in from dbapi2 import * File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in from _sqlite3 import * ImportError: No module named _sqlite3

As I have already told to, the possible reason of this problem is that the module in tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. This explanations is supported by the fact that I do not have _sqlite3.so file in my "/home/verrtex/opt/lib/python2.6/lib-dynload" directory. So, this is the problem I have to solve (I have to get this file to this directory).

I found out that to solve this problem I have to "install sqlite3 and recompile Python". I also found out that the problem can be solved by "building from source and moving the library to /usr/lib/python2.5/lib-dynload/".

However, it is not clear to me what exactly should I do. Should I install python module called "sqlite3" or I should install sqlite-database? By the way, I have already sqlite-database installed globally by the administrator. Can I use it or I still have to install my own database? By the way, I do not have root permissions. Can it be a problem? Or I need to install a python module? Is absence of root permissions a problem, in this case?

I also has been told to, to take source files from SQLite Download Page, extract archive, move to expanded directory and execute:

./configure
make
make install

Then I have to copy newly compiled files to my Python directory. Should I copy all newly compiled files? And to which exactly directory should I copy (my Python directory have some subdirectories)?

Would very appreciate any help, because I stack with this problem for a wile.

P.S. My OS is CentOS release 5.3 (Final).

+1  A: 

Your sys.path is likely not pointing to your locally installed copy, or you're not running the Python 2.6.2 you think you are.

If none of that is the case, you need the SQLite development headers (sqlite-dev or whatever), and then recompile Python. You need to pay attention at the end of the compile, because it complains about what it didn't build due to missing dependencies.

EDIT: Reread question.

EDIT 2: Also, please don't do this:

from module import *

Do this:

from module import what_i_need
import module2
Jed Smith
I am sure, I am running Python 2.6.2 (I check it with "python -V"). I think "_sqlite3.so" is a problem because it is not in "/lib-dynload/" where it should be.
Verrtex
A: 

I agree with verrtex, even I am not getting the file , it should come in /lib-dynload/ but it is not coming , and there is not errors after compilation about missing modules ,etc...

Amit Kabra