You are not logged in.

#1 2011-08-15 17:59:11

knuckles
Member
Registered: 2008-01-24
Posts: 13

#!/usr/bin/python2 points to python3

When I run /usr/bin/python2 from the command line, everything works as expected:

shunya% /usr/bin/python2    
Python 2.7.2 (default, Jun 29 2011, 11:10:00) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'2.7.2 (default, Jun 29 2011, 11:10:00) \n[GCC 4.6.1]'
>>> 

When I attempt to execute a script with python2, it uses python3 instead. For instance:

  1 #!/usr/bin/python2
  2 
  3 import sys
  4 print (sys.version)
  5 
  6 sys.exit()

gives the following output:

3.2.1 (default, Jul 11 2011, 12:37:47) 
[GCC 4.6.1]

Press ENTER or type command to continue

Any ideas?

Offline

#2 2011-08-15 18:29:26

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: #!/usr/bin/python2 points to python3

Unable to reproduce.

barrucadu on azathoth in ~/tmp 
 >>>  cat test.py
#!/usr/bin/python2

import sys
print(sys.version)
sys.exit()

barrucadu on azathoth in ~/tmp 
 >>>  ./test.py 
2.7.2 (default, Jun 29 2011, 11:10:00) 
[GCC 4.6.1]

How are you executing the file?

Offline

#3 2011-08-15 18:33:27

knuckles
Member
Registered: 2008-01-24
Posts: 13

Re: #!/usr/bin/python2 points to python3

Thank you Barrucadu. The problem was:

map <buffer> <S-e> :w<cr>:!/usr/bin/env python % <cr>

in my python.vim,

Last edited by knuckles (2011-08-15 18:33:42)

Offline

Board footer

Powered by FluxBB