I'm using redhat 5.8, which comes with python 2.4 installed automatically, but I'm using a python package that requires python 2.6 or higher. SO, I installed python 2.7 alongside 2.4, so as to not step on the system version.
Now, I'm trying to install a package through pip, and get the following error:
CompressionError: bz2 module is not available
I do, however, have the module on my machine, as evidenced when I do this the server version gives:
[~]$ python -c "import bz2; print bz2.__doc__"
The python bz2 module provides a comprehensive interface for
the bz2 compression library. It implements a complete file
interface, one shot (de)compression functions, and types for
sequential (de)compression.
and the 2.7 install errors in this way:
[~]$ python2.7 -c "import bz2; print bz2.__doc__"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named bz2
So, I have read these questions: Already installed and this very good one, but neither of these seem quite on the mark. In the first case, the advice is to install the missing piece, and the second question is to remove (or stop referencing) the extra python install.
What I want to do is put in a symlink or some such so that the python 2.7 install knows where bz2 is so that I can use pip to install a python package.
Thanks, B
EDIT: more information
So, after much research, it appears that the way the path variables are established changed dramatically in python 2.5 (probably why red hat hasn't updated).
So, in python 2.7 you can add to the PYTHONPATH variable by adding a file with the .pth extension in this folder:
/usr/local/lib/python2.7/site-packages/
I have tried 2 ways to get this to work properly.
First, I simply fed a number of the python 2.4 path files to 2.7. This caused an error of a different type:
[~]$ python2.7 -c "import bz2; print bz2.__doc__"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: /usr/lib64/python2.4/lib-dynload/bz2.so: undefined symbol: Py_InitModule4
So, that's something.
I also tried pointing the path to the libbz2.so file in /usr/lib/ which resulted in the familiar error:
[~]$ python2.7 -c "import bz2; print bz2.__doc__"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named bz2
I'm still stumped, but I feel like I'm closing in.
I could really use some input from someone with more experience setting up programming environments. I'm much more comfortable just writing code :)