Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install modules for Python 2.7 on Ubuntu 10.10?

On Ubuntu 10.10, I am unable to install lxml to python 2.7. Here are the steps I take.

sudo su -
apt-get install python2.7
apt-get install python-lxml

Note when running the install for python-lxml package, the following appeared:

INFO: using unknown version '/usr/bin/python2.7' (debian_defaults not up-to-date?)"

Importing the module in python2.6 (the version that comes standard with Ubuntu) works. However, importing the module under python2.7 does not. So how does one install Python modules to a non-default Python installation?

like image 251
paragbaxi Avatar asked Apr 27 '26 17:04

paragbaxi


2 Answers

Try to install libxml2, libxml2-dev, libxslt, libxslt-dev, python-dev. These are header files. Then try to install lxml again.

like image 135
Andrew_1510 Avatar answered Apr 30 '26 03:04

Andrew_1510


On Ubuntu 10.10 the python packages installed from the repositories get installed to /usr/lib/python2.6/dist-packages so one option is to add this path to your $PYTHONPATH environmental variable so python2.7 will look to the python2.6 directory for the libs.

What I've done on Ubuntu 10.10 is add

export PYTHONPATH="$PYTHONPATH:/usr/lib/python2.6/dist-packages"

to my .bashrc file, and also to my .gnomerc file. This sets the $PYTHONPATH for python instances started from the shell or from the gnome desktop. You should then be able to import the python libs which you have installed from the Ubuntu repositories in python2.7.

.bashrc and .gnomerc are both located in your home directory; you might have to create .gnomerc if it doesn't already exist. And one caution: I had a syntax error in my .gnomerc which stopped the gnome desktop from loading, and I couldn't log in. I had to use a recovery console to fix this syntax error and then I could log in again.

This seems a little hackish to me, so I'm interested in hearing better solutions.

like image 39
Buttons840 Avatar answered Apr 30 '26 03:04

Buttons840



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!