Python shell: Arrow keys not working in PuTTY
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Feb 23 21:07:52 EST 2015
Laura Creighton wrote:
> DO NOT REBUILD PYTHON ON CENTOS!
>
> It can break the whole package management system
> which depends on having a particular version of python installed.
>
> If you are running Centos you need to use virtualenv to be safe.
>
> Laura
Almost right!
You can install Python from source. Unzip the source tar ball, cd into the
source directory, and run:
./configure
make
BUT do *not* run `make install` as that will overwrite your system Python
and Bad Things will happen. Instead, run `make altinstall`.
Now you will have two Python installs, the stock-standard system Python is
available as "python", and the newly-installed one as "pythonX.Y" (for
version X.Y).
What I do is then add
alias python /usr/local/bin/pythonX.Y
to my .bashrc file, and use the new one. (Don't forget to change the X.Y to
whatever version you actually used.)
What if you accidentally blow away the system Python by running `make
install`? You probably won't be able to use yum to fix it, since yum relies
on the system Python. Fortunately, you haven't actually *removed* the system
Python, it's still there just hiding. First, find out which version of
Python your system Python is:
[steve at ando ~]$ ls -l /usr/bin/python*
-rwxr-xr-x 2 root root 5708 Jan 9 2013 /usr/bin/python
lrwxrwxrwx 1 root root 6 Jan 22 2013 /usr/bin/python2 -> python
-rwxr-xr-x 2 root root 5708 Jan 9 2013 /usr/bin/python2.4
This tells me that the system Python is 2.4 (well actually I already knew
that). /usr/bin/python here is a hard-link to the python2.4 executable. If I
had accidentally killed the system Python, I would see something like:
-rwxr-xr-x 2 root root 6789 Feb 24 2015 /usr/bin/python
lrwxrwxrwx 1 root root 6 Jan 22 2013 /usr/bin/python2 -> python
-rwxr-xr-x 1 root root 5708 Jan 9 2013 /usr/bin/python2.4
-rwxr-xr-x 2 root root 6789 Feb 24 2015 /usr/bin/python2.7
The /usr/bin/python is now hard-linked to the newly installed version. As
root:
rm /usr/bin/python # Die, imposter!
ln /usr/bin/python2.4 /usr/bin/python # Revive the system Python.
All fixed!
--
Steven
More information about the Python-list
mailing list