How to install pysqlite?

2019-02-24 18:20发布

问题:

I am trying to install pysqlite (Python interface to the SQLite). I downloaded the file with the package (pysqlite-2.5.5.tar.gz). And I did the following:

gunzip pysqlite-2.5.5.tar.gz
tar xvf pysqlite-2.5.5.tar
\cd pysqlite-2.5.5
python setup.py install

At the last step I have a problem. I get the following error message:

error: command 'gcc' failed with exit status 1

I found that other peoples also had this problem.

As far as I understood in the person had a problem because sqlite2 was not installed. But in my case, I have sqlite3 (I can run it from command line).

May be I should change some paths in "setup.cfg"? At the moment I have there:

#define=
#include_dirs=/usr/local/include
#library_dirs=/usr/local/lib
libraries=sqlite3
define=SQLITE_OMIT_LOAD_EXTENSION

And if I type "which sqlite3" I get:

/usr/bin/sqlite3

I saw a similar question here. The answer was "you need sqlite3-dev". But, even if it is the case, how to check if I have sqlite3-dev. And if I do not have it how to get it?

Can anybody pleas help me with that problem.

Thank you in advance.

回答1:

how to check if I have "sqlite3-dev"

That's entirely dependent on what Linux distro you're using -- is it Fedora, Suse, Ubuntu, Gentoo, Mandrake, or which other one out of the dozens out there; there are several packaging strategies and tools used to check which packages are there, get more, and so forth.

So, never ask questions about checking, getting or tweaking packages on Linux without specifying the distribution[s] of interest -- it makes it essentially impossible to offer precise, specific help.

Edit: the simplest way I know of getting details about your Linux distribution (works on all the ones I have at hand to try, but I don't have a particularly wide array...;-):

$ cat /etc/*-release
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.2"
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
...etc, etc...

This is probably going to be the contents of file /etc/lsb-release, but I'm suggesting the *-release because I think there may be some other such files involved.

Of course, if the need to check your distro applies inside a file or program, reading this file (or files) and locating specific contents will also be quite feasible; but for the purpose of informing would-be helpers about what distro you're using, the cat at the shell prompt is going to be quite sufficient;-).



回答2:

For Debian distros I fixed this problem with

sudo apt-get install libsqlite3-dev


回答3:

I was able to resolve the same build error by installing the sqlite-devel package:

sudo yum install sqlite-devel


回答4:

I had the same problem, I'm using python 2.4, neither sqlite3-dev nor libsqlite3-dev are available for CentOS.

yum install python-devel

seems to solve the issue.



回答5:

What version of Python do you have? SQLite is integrated in Python since 2.5:

http://docs.python.org/library/sqlite3.html

If you insist on compiling it yourself, the package is called sqlite3-devel, you can find it e.g. here



回答6:

You could use yum or apt-get instead first type :

    sudo yum(or apt-get) search python-sqlite3

you will get something like python-sqlite3dbm.noarch

then type :

    sudo yum(or apt-get) install python-sqlite3dbm.noarch

this way your os will install all you need for you and you wont get errors



回答7:

I had following compile errors on CentOS release 5.6:

src/cache.h:34: error: expected specifier-qualifier-list before 'PyObject_HEAD'
src/cache.h:44: error: expected specifier-qualifier-list before 'PyObject_HEAD'
src/cache.h:61: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pysqlite_NodeType'
src/cache.h:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pysqlite_CacheType'
src/cache.h:64: error: expected declaration specifiers or '...' before 'PyObject'
src/cache.h:64: error: expected declaration specifiers or '...' before 'PyObject'
src/cache.h:67: error: expected declaration specifiers or '...' before 'PyObject'
src/cache.h:67: error: expected declaration specifiers or '...' before 'PyObject'

Installing python-devel helped me too:

yum install python-devel



回答8:

I'm the one who answered the other question :) On systems that use RPM packages, i.e. you normally use 'yum' to install things, the package is named sqlite3-devel.

On most Debian based systems (i.e. you use apt-get to install packages), the package is named sqlite3-dev.

This is a very typical difference between the two, most other packages follow the same naming convention.



回答9:

I had the same trouble with gcc failing with Ubuntu Karmic. I fixed this by installing the python-dev package. In my case, I'm working with python2.4, so I installed the python2.4-dev package. The python-dev package should work for python2.6.



回答10:

Did you install the python sqlite lib?

sudo apt-get install python-sqlite


回答11:

you need to install the plug in http://yum.baseurl.org/download/yum-metadata-parser/

wget -c "http://yum.baseurl.org/download/yum-metadata-parser/yum-metadata-parser-1.1.4.tar.gz"

then install it

tar zxf yum-metadata-parser-1.1.4.tar.gz && cd yum-metadata-parser-1.1.4
/path/to/python setup.py install