1

I installed ATpy-0.9.7 on my pc successfully and I also have the Python version of "2.7.5". But when I import atpy I get the following error message:

>>> import atpy
ERROR: ImportError: No module named _sqlite3 [unknown]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "atpy/__init__.py", line 1, in <module>
    from .basetable import Table, TableSet, VectorException
  File "atpy/basetable.py", line 15, in <module>
    from . import registry
  File "atpy/registry.py", line 186, in <module>
    from . import sqltable
  File "atpy/sqltable.py", line 10, in <module>
    from . import sqlhelper as sql
  File "atpy/sqlhelper.py", line 11, in <module>
    import sqlite3
  File "/export/aibn84_2/zahra/lib/Python-2.7.5/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/export/aibn84_2/zahra/lib/Python-2.7.5/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3

I also installed db_sqlite3.egg-info. I don't know why this error message occurs!

I installed again th python2.7.5 with the following command :

./configure --prefix=$PYTHONPATH 

but I also get this error after executing make:

    Python build finished, but the necessary bits to build these modules were not found:
    _bsddb             _sqlite3           bsddb185        
    dbm                dl                 gdbm            
    imageop            sunaudiodev                        

To find the necessary bits, look in setup.py in detect_modules() for the module's name.

How could I run configure in order to install required C libraries?

Dalek
  • 4,168
  • 11
  • 48
  • 100
  • This means that the C library associated with the sqlite3 module isn't installed correctly. If you compiled Python yourself, that library only builds if you have the sqlite C library available on your host -- take a close look at the output of the Python configure script. – Charles Duffy Feb 06 '14 at 17:21
  • ...since this is an installation problem, rather than a language usage one, I wonder if it might be better placed on ServerFault or SuperUser. – Charles Duffy Feb 06 '14 at 17:23

2 Answers2

1

If you are using a self built version of Python you need to ensure that both the base and the development sqllite3 packages are installed on your system before building Python.

If they are not and, as you said, you do not have superuser privileges, you can download and build sqlite locally, and get your Python build to use that version. This blog post describes how.

Nicola Musatti
  • 17,834
  • 2
  • 46
  • 55
  • I have installed the python locally since I can not install anything as root and I am wondering whether this caused the python installation gets messed up??!! Could you explain your point more? – Dalek Feb 06 '14 at 17:31
  • If you *built* Python locally, i.e. by running `./configure` and than `make ...`, those modules that are implemented in C, like `sqllite3`, require the corresponding development packages, which contain header files and possibly other source files. – Nicola Musatti Feb 06 '14 at 17:37
  • I ran `./configure --prefix=MY_PYTHON_PATH` command. How could I provide the corresponding packages, when I install a software like this? – Dalek Feb 06 '14 at 19:05
  • should I change the path of sqlite in the `setup.py` script of python?`# We hunt for #define SQLITE_VERSION "n.n.n" # We need to find >= sqlite version 3.0.8 sqlite_incdir = sqlite_libdir = None sqlite_inc_paths = [ '/usr/include', '/usr/include/sqlite', '/usr/include/sqlite3', '/usr/local/include', '/usr/local/include/sqlite', '/usr/local/include/sqlite3', ]` – Dalek Feb 06 '14 at 19:32
  • I installed "Anaconda 1.8.0" and my problem solved. It seems it is much easier to mount all the libraries which I needed on anaconda! Thanks any way! – Dalek Feb 07 '14 at 12:55
0

According to this question

How can I install sqlite3 to Python?

...you shouldn't have to install anything to get sqlite3 for python. Before I could import atpy I did have to install astropy (which was quite involved). After I did that, everything worked.

Community
  • 1
  • 1
Wolf
  • 4,254
  • 1
  • 21
  • 30