Summary: Several utilities do not work after I installed more recent python on my Ubuntu machine. Why?
My only experience with Linux is Ubuntu 12.04 and so far I've relied on apt-get primarily for installing packages (i.e. very little experience with ./configure && make && sudo make install).
More recent versions of python do not appear to be available via apt-get, so I downloaded installed python 2.7.8 with your typical
./configure && make && sudo make install
Now, I have essentially zero knowledge of package management, so with that in mind...
For whatever reason I had to manually replace the python symbolic link in /usr/bin with the appropriate reference to the new binary (I thought install would do this). I still have python 2.7.3 on my machine, by the way.
i.e.
cd /usr/bin
sudo rm python
ln -s /location/of/new/python python
Now, in preparation for writing a totally different question, I wanted to confirm my version of Ubuntu with
lsb_release -a
but I get
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 26, in <module>
import lsb_release
ImportError: No module named lsb_release
I get the sense that this will keep happening with lots of utilities until I can tell my system somehow to see the ubuntu installed (apt-get) python modules.
For example, I had pip installed and working, but now if I type
pip install lsb_release
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
Is there an easy (or not) way to resolve all these dependency problems?
I now have IDLE working (running) with the new Python 2.7.8 after installing tk-dev
sudo apt-get install tk-dev
(it was previously working without this step)
but if I open a python script with IDLE by right clicking and going to IDLE it cannot see my wxPython (wx) libraries, which I've also freshly built. I had this problem from the terminal also but resolved it according to
How can I get IDLE to see the wx modules when I right click on a python file and go to IDLE? If I run IDLE from the terminal it can see the wx module (i.e. import wx
works).
I know this question is all over the place but I'm not sure where to start.
Thanks.
Additional information that might be relevant:
which python
/usr/bin/python
python --version
Python 2.7.8
python -m site
sys.path = [
'/usr/lib/python2.7',
'/usr/local/lib/python27.zip',
'/home/jpf/src/Python-2.7.8/Lib',
'/home/jpf/src/Python-2.7.8/Lib/plat-linux2',
'/home/jpf/src/Python-2.7.8/Lib/lib-tk',
'/home/jpf/src/Python-2.7.8/Lib/lib-old',
'/home/jpf/src/Python-2.7.8/build/lib.linux-i686-2.7',
'/home/jpf/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages/wx-3.0-gtk2',
'/usr/local/lib/python2.7/dist-packages',
'/usr/local/lib/python2.7/dist-packages/wx-2.9.4-gtk2',
]
(This correctly has two versions of wxPython installed.) But here's where it looks inconsistent to me...
locate lsb_release.py
/usr/lib/python2.7/dist-packages/lsb_release.py
/usr/lib/python2.7/dist-packages/lsb_release.pyc
/usr/lib/python3/dist-packages/lsb_release.py
/usr/share/pyshared/lsb_release.py
The location of python module lsb_release is /usr/lib/python2.7/dist-packages
while python appears to be searching in /usr/local/lib/python2.7/dist-packages
. What did I do wrong?
Partial Answer
Beginning to understand the issue, and as expected it is due to my ignorance of how Linux and Ubuntu work.
When in Ubuntu the administrator installs a given python related python-module via sudo apt-get install python-module
it is placed in /usr/local/lib/pythonX.Y/dist-packages
. When the admin installs a python program via the same method it appears to be located in the /usr/lib/pythonX.Y/dist-packages
. For example, when I installed pip I installed via sudo apt-get install python-pip
. This created the directory /usr/lib/python2.7/dist-packages/pip
. When I installed xlwt
with pip, a directory /usr/local/lib/pythonX.Y/dist-packages/xlwt
was created. This may not be a hard and fast rule, but it seems that at least python modules, when installed with either apt-get or pip are all installed in /usr/local/lib/pythonX.Y/dist-packages
.
This is contrasted with the site-packages location /usr/local/lib/pythonX.Y/site-packages
(/usr/lib/pythonX.Y/site-packages
doesn't exist), to which packages are added when the admin installs a package manually as I did with wxPython 3.0 (see /usr/local/lib/python2.7/site-packages/wx-3.0-gtk2
above, as distinct from /usr/local/lib/python2.7/dist-packages/wx-2.9.4-gtk2
which I installed with special instructions to integrate into Ubuntu's package manager).
This is described here:
What's the difference between dist-packages and site-packages?
Related is the difference between /usr/lib
and /usr/local/lib
described here:
What's the difference between /usr/local/lib/python2.6 and /usr/lib/python2.6?
The freshly installed Python 2.7.8 did not "see" the directory /usr/lib/python2.7/dist-packages/
which includes the necessary module lsb_release
because it was not set up to see it via the package manager (via apt-get
). Since I installed it manually (i.e. with ./configure && make && make install
) it saw only /usr/local/lib/python2.7/
.
I'd erase this question but maybe it will be helpful to some other newbie. Admins please feel free to erase if appropriate.