I installed Python 2.7.9 on Ubuntu 14.04 by compiling its source, by .configre
, make
, and make altinstall
. make altinstall
is because I don't want to overwrite the default Python 2.7.6. My self installed 2.7.9 is in /usr/local/bin/python2.7
and many other files in other directories under /usr/local
. From README in the source installation package:
On Unix and Mac systems if you intend to install multiple versions of
Python using the same installation prefix (–prefix argument to the
configure script) you must take care that your primary python
executable is not overwritten by the installation of a different
version.All files and directories installed using "make altinstall" contain
the major and minor version and can thus live side-by-side. "make
install" also creates ${prefix}/bin/python which refers to
${prefix}/bin/pythonX.Y.If you intend to install multiple versions using the same prefix you
must decide which version (if any) is your "primary" version. Install
that version using "make install". Install all other versions using
"make altinstall".For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6
being the primary version, you would execute "make install" in your
2.6 build directory and "make altinstall" in the others.
Now I want to uninstall my self installed 2.7.9.
-
Fortunately I still have the source code, but unfortunately, the
Makefile doesn't have uninstall section$ sudo make uninstall make: *** No rule to make target `uninstall'. Stop.
-
Then I tried another way: first create a deb from the source and
compilation, install the deb (hopefully overwriting the installed
files frommake altinstall
), and then uninstall the deb.But when I create the deb file by
checkinstall
, I am not sure if
and how I should do differently formake altinstall
from formake install
. What I tried is:$ checkinstall altinstall ... Installing with altinstall... ========================= Installation results =========================== /var/tmp/tmp.4ZzIiwqBNL/installscript.sh: 4: /var/tmp/tmp.4ZzIiwqBNL/installscript.sh: altinstall: not found ...
I wonder how I can create a deb so that installing the deb will
duplicate the installation process ofmake altinstall
? -
Or what is your way of uninstalling my python 2.7.9?
Note: the source package in the first link also has setup.py
, install-sh
besides README
.
Best Answer
The following commands will remove your
make altinstall
-ed python:You might also have to do
Although
make altinstall
has served me well if the "system python" has a different major.minor number from the one you install, it doesn't work that well if only the micro number (the third position) differs. That number is excluded from the installed binary, and you end up with two versions pythonX.Y. This was always a problem but once distributions started shipping with system utilities based on 2.7.X this problem has been more severe as 2.7 is supposed to be the last of the Python2 series.IMO the best approach to solve this problem is to prevent it from becoming one: configure python to install in a directory not used by any other python. On my system they go under
/opt/python/X.Y.Z
.To use any of the Pythons installed there you use
[virualenv][1]
to make a new environment:or use
[virtualenvwrapper][2]
. I have some aliases for the latest versions in the series I work with.If you are using
tox
for testing against multiple versions (you should) the following alias will help it find the various version:(these are currently the latest versions, I use a slightly different setup by maintaining links from
/opt/python/2.7
to the latest/opt/python/2.7.9
, and for the other minor numbers as well, within the process for downloading, building and installing a new python version)These installs are never used directly. They are always used as the basis for
virtualenv
environments only, hence I don't care that they are not in my normal PATH.