Sign up ×
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.

In my Suse system I have these 2 versions of Python:

# which python2.6
# /usr/bin/python2.6

# which python2.4
# /usr/local/bin/python2.4

2.6 is the system one, and 2.4 was compiled by me.

If I try to import a package using the 2.4 version:

# python2.4 -c "import bz2; print bz2.__doc__"

I get the following error:

# ImportError: No module named bz2

What is the correct way to proceed with this?

share|improve this question
    
    
@MohsenPahlevanzadeh I have no problems with system Python2.6, so the modules are installed. But I don't know how to handle it for Python2.4 –  ftkg Oct 15 '13 at 20:32
    
please refer to supported versions, some of module are supported from x and higher milestone of python. –  PersianGulf Oct 15 '13 at 20:34
    
If it is a manually compiled python installation, then you need to install the bzip2 and bzip2-devel packages and then recompile and reinstall python. –  forcefsck Oct 15 '13 at 20:47
    
I might be wrong, but don't you need to set PYTHONPATH correctly so that Python 2.4 looks in the right place? –  peterph Oct 15 '13 at 22:34

1 Answer 1

up vote 1 down vote accepted

It would appear that there is a bz2module.c that comes with the Python 2.4 source, but does not appear to be compiled by default and there is nothing in Modules/Setup for it. Likely because the development package for bz2 is not installed by default. Try to find the bzlib.h file on your system:

$ find /usr/include -name bzlib.h

If that does not exist, then install the appropriate library package (libbz2-dev on Debian/Ubuntu).

After that try adding the following to Modules/Setup.local and then recompiling python 2.4.

bz2 bz2module.c
share|improve this answer
    
Tried that, but got errors during make :libpython2.4.a(bz2module.o): In function 'BZ2Decomp_decompress': /home/incoming/Python-2.4.2/./Modules/bz2module.c:1841: undefined reference to 'BZ2_bzDecompress' any idea? –  ftkg Oct 16 '13 at 15:20
    
It isn't failing on my side, so I'm not sure where the problem could be. Since the build is finding bzlib.h, the most likely reason is that there is a version mismatch between what you installed for the bzip2 development package and what is expected in Python. The version of libbz2-dev on my system is 1.0.6-1, what was installed on your system? –  Arcege Oct 17 '13 at 13:45
    
Just took an alternative path. But you're probably correct, will mark your answer. –  ftkg Oct 25 '13 at 19:19

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.