Python version changes, sys.executable does not

Jim Langston tazmaster at rocketmail.com
Thu Jul 19 21:29:31 EDT 2007


"Jeffrey Froman" <jeffrey at fro.man> wrote in message 
news:139v9oe22rihh40 at corp.supernews.com...
> Hello All,
>
> I have two python versions installed, one in /usr/bin, and one in
> /usr/local/bin. However, when invoking python without a full path,
> I get the wrong executable with the right sys.executable string!
> ----------------------------------------------------------------------------
> [root at M1 ~]# ls -l /usr/local/bin/python*
> -rwxr-xr-x  2 root root 3783810 Jul 19 09:15 /usr/local/bin/python
> -rwxr-xr-x  2 root root 3783810 Jul 19 09:15 /usr/local/bin/python2.5
> -rwxr-xr-x  1 root root    1281 Jul 19 09:16 
> /usr/local/bin/python2.5-config
> lrwxrwxrwx  1 root root      16 Jul 19 09:16 
> /usr/local/bin/python-config -> python2.5-config
>
> [root at M1 ~]# ls -l /usr/bin/python*
> -rwxr-xr-x  2 root root 5396 May  2 16:28 /usr/bin/python
> lrwxrwxrwx  1 root root    6 Jul 18 12:20 /usr/bin/python2 -> python
> -rwxr-xr-x  2 root root 5396 May  2 16:28 /usr/bin/python2.3
>
> [root at M1 ~]# which python
> /usr/local/bin/python
>
> [root at M1 ~]# /usr/local/bin/python -c "import sys; print sys.executable; 
> print sys.version; set()"
> /usr/local/bin/python
> 2.5 (r25:51908, Jul 19 2007, 09:13:48)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)]
>
> [root at M1 ~]# env python -c "import sys; print sys.executable; print 
> sys.version; set()"
> /usr/local/bin/python
> 2.5 (r25:51908, Jul 19 2007, 09:13:48)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)]
>
> [root at M1 ~]# python -c "import sys; print sys.executable; print 
> sys.version; set()"
> /usr/local/bin/python
> 2.3.4 (#1, May  2 2007, 19:26:00)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)]
> Traceback (most recent call last):
>  File "<string>", line 1, in ?
> NameError: name 'set' is not defined
> ---------------------------------------------------------------------------------
>
>
> On a different machine, with same setup (as far as I can tell), I get the 
> expected
> results:
> ---------------------------------------------------------------------------------
> [root at M2 ~]# /usr/local/bin/python -c "import sys; print sys.executable; 
> print sys.version; set()"
> /usr/local/bin/python
> 2.5 (r25:51908, Feb  8 2007, 16:29:18)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)]
>
> [root at M2 ~]# env python -c "import sys; print sys.executable; print 
> sys.version; set()"
> /usr/local/bin/python
> 2.5 (r25:51908, Feb  8 2007, 16:29:18)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)]
>
> [root at M2 ~]# python -c "import sys; print sys.executable; print 
> sys.version; set()"
> /usr/local/bin/python
> 2.5 (r25:51908, Feb  8 2007, 16:29:18)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)]
> ---------------------------------------------------------------------------------
>
> Can anyone tell me what might be causing the erroneous behavior in the 
> first example?

er, of course I meant python2.3 before python2.5 





More information about the Python-list mailing list