There are two Python interpreters installed:
[user@localhost ~]$ /usr/bin/python -V && /usr/local/bin/python -V
Python 2.4.3
Python 2.7.6
Sudo changes PATH
for every command it runs as follows:
[user@localhost ~]$ env | grep PATH && sudo env | grep PATH
PATH=/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/user/bin
PATH=/usr/bin:/bin
I run a test script:
[user@localhost ~]$ cat what_python.py
#!/usr/bin/env python
import sys
print sys.executable
print sys.version
[user@localhost ~]$ sudo python what_python.py
/usr/bin/python
2.7.6 (default, Feb 27 2014, 17:05:07)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]
and get path to Python 2.4.3 in sys.executable
and version 2.7.6 reported in sys.version
. Clearly sys.executable
and sys.version
do not match. Taking into account how sudo modifies PATH I can understand the value of sys.executable
. However, why does sys.version
report version 2.7.6 and not version 2.4.3, which would match usr/bin/python
path reported by sys.executable
?
This is a follow-up to my question Sudo changes PATH, yet executes the same binary