Ubuntu packages needed to compile Python 2.7
Asked Answered
G

3

14

I've tried to compile Python 2.7 on Ubuntu 10.4, but got the following error message after running make:

Python build finished, but the necessary bits to build these modules were not found:
_bsddb             bsddb185           sunaudiodev     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

What packages do I need? (setup.py was not helpful)

Gatehouse answered 28/9, 2010 at 13:17 Comment(2)
I would try going into Synaptic and searching Python and download all the dev kits, etc.Kristlekristo
I would think this would be better for unix.se, ubuntu.se, superuser or serverfault.Playoff
T
16

Assuming that you have all the dependencies installed (on Ubuntu that would be bunch of things like sudo apt-get install libdb4.8-dev and various other -dev packages, then this is how I build Python.

tar zxvf Python-2.7.1.tgz
cd Python-2.7.1

# 64 bit self-contained build in /opt
export TARG=/opt/python272
export CC="gcc -m64" 
export LDFLAGS='-Wl,-rpath,\$${ORIGIN}/../lib -Wl,-rpath-link,\$${ORIGIN}/../lib -Wl,--enable-new-dtags'
./configure --prefix=$TARG --with-dbmliborder=bdb:gdbm --enable-shared --enable-ipv6
make
make install

The only modules that don't build during make are:

_tkinter - I don't do GUI apps and would use wxWindows if I did
bsddb185 - horribly obsolete version of bdb
dl - deprecated in 2.6              
imageop - deprecated in 2.6
sunaudiodev - obsolete interface to some SparcStation device I think

Next I collect any .so files that are not already in the Python install directories and copy them over:

# collect binary libraries ##REDO THIS IF YOU ADD ANY ADDITIONAL MODULES##
cd /opt/python272
find . -name '*.so' | sed 's/^/ldd -v /' >elffiles
echo "ldd -v bin/python" >>elffiles
chmod +x elffiles
./elffiles | sed 's/.*=> //;s/ .*//;/:$/d;s/^              *//' | sort -u | sed 's/.*/cp -L & lib/' >lddinfo
# mkdir lib
chmod +x lddinfo
./lddinfo

And then add setuptools for good measure

#set the path
export PATH=/opt/python272/bin:$PATH

#install setuptools
./setuptools-0.6c11-py2.7.egg

At this point I can make a tarball of /opt/python272 and run it on any 64-bit Linux distro, even a stripped down one that has none of the dependencies installed, or a older distro that has old obsolete versions of the dependencies.

I also get pip installed but at this point there is a gap in my notes due to some failed struggles with virtualenv. Basically virtualenv does not support this scenario. Presumably I did easy_install pip and then:

export LD_RUN_PATH=\$${ORIGIN}/../lib
pip install cython
pip install {a whole bunch of other libraries that I expect to use}

After I'm done installing modules, I go back and rerun the commands to collect .so files, and make a new tarball. There were a couple of packages where I had to muck around with LDFLAGS to get them to install correctly, and I haven't done enough thorough testing yet, but so far it works and I'm using this Python build to run production applications on machines that don't have all the support libraries preinstalled.

Thesis answered 17/6, 2011 at 19:5 Comment(1)
Great point that just because a module can't be found when you're building it, doesn't mean you need it.Christ
D
6

sudo apt-get build-dep python2.6 python-gdbm python-bsddb3 (Use python2.7 on maverick).

For more information, see this answer. Also look at this page, which applies equally for building on Lucid.

Demosthenes answered 28/9, 2010 at 13:39 Comment(1)
The package "build-dep" cannot be found on my system.Gatehouse
S
6

Those are older, (mostly depreciated) modules that you probably won't use. You should be able to safely ignore the warnings.

The one that you may want to worry about trying to fix is _bsddb, which should go away once you install Berkeley DB 4.8... I'm not sure if it's in the Ubuntu repos or not. (edit: apparently it's the db package)

bsddb185 is an older version of the Oracle Berkley Database module. You can safely ignore it as far as I know.

sunaudiodev is depreciated, undocumented, I doubt you'd ever need to use it anyway. You should be able to safely ignore it.

Hope that helps a bit, anyway...

Skirl answered 28/9, 2010 at 13:41 Comment(1)
My list of ignores on Linux are _tkinter, bsddb185, dl, imageop, sunaudiodevThesis

© 2022 - 2024 — McMap. All rights reserved.