6

I'm new to python and ubuntu. I'm trying to install python 2.6.5 on ubuntu 12.10. I already have python 2.7.3 and am trying to install 2.6.5 side by side the existing python. I get the following error when executing make:

Failed to find the necessary bits to build these modules:
_bsddb             bsddb185           dl
imageop            linuxaudiodev      ossaudiodev
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:
_curses            _curses_panel      _ssl

I am most worried about the _ssl module. I used ./configure --with-ssl, as mentioned in another post, but the message is still the same. Any pointers appreciated.

Additional note: make used to complain that it could not build bz2 either, but I fixed that with this post entry recompiling bzip2. Now it's down to _ssl. I'm not sure if I need _curses.

Edit: Found make log file and it looks like this is due to the fact that python 2.6.5 supports ssl v2, while this support was removed in Ubuntu. Log file contains:

*** WARNING: renaming "_ssl" since importing it failed: build/lib.linux-x86_64-2./_ssl.so: undefined symbol: SSLv2_method

This blog has python 2.6.8 rebuilt without the ssl v2 support. I'm trying their changes in the 2.6.5 source now.

Edit 2: Modifying 2.6.5 sources as noted above and removing ssl v2 support fixed the problem with _ssl module not building. Also, here is a list of packages I tried installing earlier:

apt-get install libreadline-dev
apt-get install libssl-dev (already installed)
apt-get install libbz2-dev (already installed)
apt-get install build-essential (already installed)
apt-get install sqlite3
apt-get install tk-dev
apt-get install libsqlite3-dev
apt-get install libc6-dev (already installed)
apt-get install libgdbm-dev
apt-get install libncursesw5-dev

Here is full output from make:

running build
running build_ext
building '_curses' extension
gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict prototypes -I. -I/tmp/nimbula/Python-2.6.5/./Include -I. -IInclude -I./Include -I/usr/local/include -I/tmp/nimbula/Python-2.6.5/Include -I/tmp/nimbula/Python-2.6.5 -c /tmp/nimbula/Python-2.6.5/Modules/_cursesmodule.c -o build/temp.linux-x86_64-2.6/tmp/nimbula/Python-2.6.5/Modules/_cursesmodule.o
building '_curses_panel' extension
gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I/tmp/nimbula/Python-2.6.5/./Include -I. -IInclude -I./Include -I/usr/local/include -I/tmp/nimbula/Python-2.6.5/Include -I/tmp/nimbula/Python-2.6.5 -c /tmp/nimbula/Python-2.6.5/Modules/_curses_panel.c -o build/temp.linux-x86_64-2.6/tmp/nimbula/Python-2.6.5/Modules/_curses_panel.o

Failed to find the necessary bits to build these modules:
_bsddb             bsddb185           dl
imageop            linuxaudiodev      ossaudiodev
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:
_curses            _curses_panel

running build_scripts

Edit 3: Yay, thank you guys for asking these questions. When I looked at the packages I installed earlier, one was clearly not looking good, the libncursesw5-dev (since it has a version in it and I got it from an old post). I tried the following and it solved the problem of _curses and _curses_panel not building:

apt-get install libncurses-dev

After installing libncurses-dev, I executed: make clean, ./configure --with-ssl, make.

Now the output from make is:

running build
running build_ext

Failed to find the necessary bits to build these modules:
_bsddb             bsddb185           dl
imageop            linuxaudiodev      ossaudiodev
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

running build_scripts
Community
  • 1
  • 1
Lidia
  • 2,005
  • 5
  • 25
  • 32
  • This isn't a programming question. – Groditz Oct 02 '13 at 23:44
  • Why do you want to install an old version anyway? – Wooble Oct 02 '13 at 23:45
  • Wait, you rebuilt `bzip2` yourself instead of just installing the packages? – abarnert Oct 02 '13 at 23:48
  • @Wooble - I need this particular version for testing our product with nosetest. – Lidia Oct 03 '13 at 01:47
  • @abarnert I tried installing bzip2 package but it was telling me that the package was already installed. Yet, python 2.6.5 make was not able to build bz2. I searched online and found a solution that worked (linked in my question above). – Lidia Oct 03 '13 at 01:49
  • @Lidia: If you want to build something that requires `bzip2`, you need `bzip2-dev`. Do you not understand that after reading my answer? If not… what can I do to make it clearer? – abarnert Oct 03 '13 at 01:58
  • @abarnert I understand your answer. However, for both bz2 and _ssl the -dev libraries were already on the system (at least that's what it was telling me when I was trying to install them, please see Edit 2 in my question). The solution turned out to be different and I'll summarize it shortly. – Lidia Oct 07 '13 at 22:41
  • @Lidia: OK, so not having the -dev packages was _part_ of your problem, but you have at least two _other_ problems. Most of the still missing modules seem to be similar problems with requirements—`bsddb185` will need an old (1.85) version of BSD's DB library, which very few linux boxes have by default; `linuxaudiodev` needs the olds-style `` interface, which you probably don't have; etc. – abarnert Oct 07 '13 at 22:57
  • @abarnert Interestingly both `bz2` and `ssl` -dev packages were already on the system, when I tried to install them with apt-get. I am no certain that I need `bsddb` or `linuxaudiodev` packages. Anyhow, for what it's worth, we moved away from this system and got an ubuntu 10.04 installed on a different machine with python 2.6.5 - just to make sure everything works as expected. – Lidia Oct 09 '13 at 01:08
  • I can confirm that bz2 and curses remain a problem building python 3.6, when bz2 and curses have been installed from source. @ all the h8ers, not everyone has the privilege of being able to sudo on the machines they use. – Him Jun 28 '18 at 13:44
  • @Lidia, I managed to get python3.6 to compile with bz2 functionality with your suggestions. Did you ever get curses to work? I tried compiling it with the -fPIC flag. I was getting an error that it couldn't find curses.h, so I cp'd everything from include/ncurses to include/, and that error went away, but it still says python "failed to build _curses"... – Him Jun 28 '18 at 15:13
  • @Scott - unfortunately it was too long ago and I do not recall if I managed to build _curses. I have not worked on Ubuntu since. – Lidia Aug 08 '18 at 01:13

2 Answers2

3

Here is how I resolved pythong 2.6.5 installation on ubuntu 12.10:

1.) I tried to install the following libraries (some were already on the system):

apt-get install libreadline-dev
apt-get install libssl-dev (already installed)
apt-get install libbz2-dev (already installed)
apt-get install build-essential (already installed)
apt-get install sqlite3
apt-get install tk-dev
apt-get install libsqlite3-dev
apt-get install libc6-dev (already installed)
apt-get install libgdbm-dev
apt-get install libncurses-dev

2.) Issue with bz2 module not building:

a.) I downloaded bz2 source from http://www.bzip.org/downloads.html. b.) Modified Makefile and changed cc=gcc to 'cc=gcc -fPIC` following this post. c.) Executed make and make install. d.) Tested bz2 with the following code from command line: python -c "import bz2; print bz2.doc"

3.) Issue with _ssl module not building:

a.) Fixed ssl by removing ssl v2 from python source. Followed instructions in this blog by Michael Schurter. It worked like a charm.

4.) At this point I installed Python 2.6.5 using make altinstall, as to not overwrite the existing python. I pointed /usr/bin/python to my new python installation. Still a couple of things were missing.

5.) Added ez_setup: curl -O https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py python ez_setup.py

6.) Added pip: easy_install -U pip

7.) Installed setuptools: pip install setuptools

At this point it looks like it's all working!

Lidia
  • 2,005
  • 5
  • 25
  • 32
  • Pointing /usr/bin/python at your new Python may not be a good idea. I don't know of any modern linux distro that doesn't come with something already at /usr/bin/python, and have hundreds of scripts that expect it to be the specific version that the distro is built around. This site is full of horror stories from people who upgraded /usr/bin/python that way and ended up with apt-get/yum or some other crucial tool no longer working; downgrading is even more dangerous. – abarnert Oct 09 '13 at 01:33
  • Also, installing `pip` via `easy_install` has been deprecated for a long time; the preferred solution is the [`get-pip.py`](http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-pip) script. It probably doesn't matter, but it's worth getting in the habit, because `easy_install` could go away in the next packaging-system shakeup. – abarnert Oct 09 '13 at 01:40
  • Thank you for the comments. It's all a learning process for me. To answer the first concern: I installed python 2.6.5 instead of upgrading the default python at /usr/bin/python precisely because of the issues I've read about upgrading/downgrading default python. In case things don't work as expected, one can always point /usr/bin/python back to the default install and all is good again. – Lidia Nov 13 '13 at 01:27
  • I was not aware of get-pip.py. Will try it next time. One thing to note: we had issues installing various tools the usual way because of the corporate proxy and had to resolve to other means that worked. Not sure if this was in this category. – Lidia Nov 13 '13 at 01:28
  • In my case, libssl needed to be downgraded to liabssl1.0-dev for python 2.7.5 on ubuntu 18.04 – user8162 Feb 19 '21 at 15:42
2

You haven't given us enough information to actually know what happened; build output and build logs exist for a reason…

But I can guess with about 80% confidence:

You don't have the right headers installed to build them.

For example, if you've installed the dpkg for libssl but not for libssl-dev, you won't be able to build _ssl. On Ubuntu, just sudo apt-get install libssl-dev and fix that. On different distros, it may be something like libssl-devel, ssl-dev, etc. But the basic concept of development pacakages is the same everywhere: to run a program that requires foo, you only need the foo package, but to build a program that requires foo, you need the foo development package as well.

For some of these libraries, it's not quite as obvious which package you're missing, but you should still be able to tell the name of the library or header file it couldn't find by looking at the logs, and you can search, or ask on an Ubuntu forum, to find out which package provides that missing file.

abarnert
  • 354,177
  • 51
  • 601
  • 671
  • This library is not found (libssl-devel) but I already had libssl-dev (please see my Edit2 above). I added more information including output from make in the question above. Where can I find the build log? Thanks. – Lidia Oct 03 '13 at 01:57
  • Btw, I resolved the issue with _ssl not building by removing references to ssl v2 in python 2.6.5 source (as per [this blog](http://blog.schmichael.com/2012/05/29/building-python-2-6-8-on-ubuntu-12-04/)). Now it's only _curses left... – Lidia Oct 03 '13 at 01:59