Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to install pysqlite using pip under a virtualenv in FreeBSD 7.3, with Python version 2.6.2. I didn't have any issues for installing other packages like Django, PIL etc. All of them I installed after activating virtualenv only. But I get a huge error for pip install sqlite. Here's the tail of the error

src/module.c:426: warning: implicit declaration of function 'sqlite3_libversion'
src/module.c:426: warning: passing argument 1 of 'PyString_FromString' makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1
Command /usr/home/myuser/python-sites/virtpython/bin/python -c "import setuptools;__file__='/usr/home/myuser/python-sites/virtpython/build/pysqlite/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /usr/tmp/pip-N3U6Px-record/install-record.txt --single-version-externally-managed --install-headers /usr/home/myuser/python-sites/virtpython/include/site/python2.6 failed with error code 1 in /usr/home/myuser/python-sites/virtpython/build/pysqlite
Exception information:
Traceback (most recent call last):
  File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/basecommand.py", line 107, in main
    status = self.run(options, args)
  File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/commands/install.py", line 261, in run
    requirement_set.install(install_options, global_options)
  File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/req.py", line 1166, in install
    requirement.install(install_options, global_options)
  File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/req.py", line 589, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/home/myuser/python-sites/virtpython/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg/pip/util.py", line 612, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/home/myuser/python-sites/virtpython/bin/python -c "import setuptools;__file__='/usr/home/myuser/python-sites/virtpython/build/pysqlite/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /usr/tmp/pip-N3U6Px-record/install-record.txt --single-version-externally-managed --install-headers /usr/home/myuser/python-sites/virtpython/include/site/python2.6 failed with error code 1 in /usr/home/myuser/python-sites/virtpython/build/pysqlite

'virtpython' is my virtualenv

% pkg_info | grep sqlite
sqlite-2.8.17_1     An SQL database engine in a C library
sqlite3-3.6.11      An SQL database engine in a C library

If there is a sqlite devel package for FreeBSD, where can I find it? Or the issue is something else??

share|improve this question
    
maybe you need to pass -I/usr/local/include as CPPFLAGS to gcc –  arved Oct 31 '12 at 16:47

4 Answers 4

up vote 2 down vote accepted

I've run into a similar problem, and the only solution I've found is to go into the pip build dir (/tmp/pip-{random hash}, can usually be found in the tail end of the error, may also be /usr/tmp/, or named pysqlite, depends on your setup) and alter the pysqlite setup.cfg. When downloaded it looks like this:

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

When I uncomment the include_dirs and library_dirs, pysqlite will install fine. The downside of this, is that I've yet to find a way to easily automate this step, so it needs to be done with every virtualenv set up. It's ugly, unpleasant, and a pain in the ass, but it does let pysqlite be installed.

Hope this helps.

PS If you're trying to run the pip install in a virtualenv, the downloaded files are likely to be found in {virtualenv}/build/pysqlite.

share|improve this answer
    
Wow!!, great dude, after uncommenting those lines, and doing python setup.py install, It Installed !! Thanks :) –  Vishnu Kumar Nov 27 '12 at 12:58
    
@SusanWright: if this is still a problem for you, you might want to have a look at my answer (not sure if it translates to FreeBSD though). –  Paul D. Waite May 16 '13 at 20:20

I don't know if this will answer your question. This is just what I would try.

  1. Try to install an earlier version of sqlite by specifying a version for example:

    pip install sqlite==2.7
    
  2. Try to build sqlite from a tarball. Just to see if the problem is in your system setup. If yes, it is probably easier to debug it this way directly without pip. Once that's sorted out, pip should also be able to do it, or at least you will know that something's fishy in your pip setup.

share|improve this answer
    
As per the first point, i tried pip install sqlite==2.6.2 as 2.6.3 is latest, but same error. Then i tried setup.py install from the tarball but still same error. –  Vishnu Kumar Oct 31 '12 at 9:28
    
in that case, it looks like something's wrong with the libraries in your system that sqlite depends on. Perhaps you can try to reinstall them if possible. Basically reinstall dependencies until everything is nice and clean. It might also be a good idea to create a completely clean VM and see if it works there. –  janos Oct 31 '12 at 10:23
    
ya thats what i too doubted. The issue is the FreeBSD server is being managed by a hosting company and i dont have root access. They claim that sqlite libraries are installed. Thats why i need to give them clear instructions on which package to install/reinstall. –  Vishnu Kumar Oct 31 '12 at 11:38
    
Crap. I'm out of ideas then... –  janos Oct 31 '12 at 13:07

I encountered a similar problem trying to install pysqlite in a virtualenv on Debian wheezy.

I found this article:

Which mentioned that I might need to install the dev version of libsqlite3 on Debian to allow pysqlite to be installed in the virtualenv:

sudo apt-get install libsqlite3-dev

I tried this, and suddenly pysqlite installed fine in my virtualenv.

share|improve this answer
1  
Thanks Paul, but this wont work in FreeBSD and also my env was a shared server, so no permission to install packages. Anyways thanks for sharing :) –  Vishnu Kumar Jun 10 '13 at 10:00
    
@VishnuKumar: ah gotcha - yup, I hadn't realised how different FreeBSD was from Debian, I'm a bit of a Unix/Linux noob. –  Paul D. Waite Jun 10 '13 at 10:54

This works well enough. FIrstly download and compile sqlite to your local machine (not the venv.). sudo pip install sqlite should do it ironically. Now add the below to your ~/.pydistutils.cfg

## Exclusively here to allow pysqlite to compile in a venv.
[build_ext]
include_dirs=/usr/local/include
library_dirs=/usr/local/lib

pip inside the venv will now compile the pysqlite against the /usr/local/lib. THis might break isolation - the pysqlite depends on libraries outside of the venv. If this bothers you I am afraid the best bet is jails or LXC

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.