1

I am using Python in Apache on a Raspberry Pi. The first line of the Python files has the following line:

#!/usr/bin/env python

What does it mean? The /usr/bin/env folder contains no files. My Python executable is the symbolic link /usr/bin/python.

The above works fine and it runs Python 2.7, the one pointed to by /usr/bin/python. If I want to use Python 3 can do it by just changing this line to some appropriate values?

user2864740
  • 60,010
  • 15
  • 145
  • 220
Old Geezer
  • 14,854
  • 31
  • 111
  • 198
  • 1
    It's called the shebang line, and `/usr/bin/env` should be an executable file. – Alexander O'Mara Dec 16 '15 at 04:19
  • Do you have a `python3` binary, or something similarly named? – Alexander O'Mara Dec 16 '15 at 04:20
  • `/usr/bin/env` is a program, not a folder: it finds and launches `python` (or whatever was supplied as an argument). This allows python (or whatever) to be installed in different locations which may differ between systems while maintaining a portable script. There should be a `python3` available if Python 3 is installed. – user2864740 Dec 16 '15 at 04:21
  • @user2864740 My mistake. Yes, `/usr/bin/env` is some file and not a folder. If I want to use Python 3, can I change it to `/usr/bin/python3.4` or `/usr/bin/env python3`? On my Pi, `/usr/bin/env/python3` is a symbolic link to `/usr/bin/python3.4`. – Old Geezer Dec 16 '15 at 04:44
  • `/usr/bin/env python3` - use Python 3. `/usr/bin/env python` - use the "default" Python, probably still Python 2 where such is installed. – user2864740 Dec 16 '15 at 04:45
  • Thanks. The duplicate reference actually explains everything. – Old Geezer Dec 16 '15 at 04:45

0 Answers0