I have installed Python2.7 in my Linux Centos which comes with a default Python2.6 installation,
Default Python
[root@linuxhost PythonProjects]# python -V
Python 2.6.6
Default Python2.7
[root@linuxhost PythonProjects]# python2.7 -V
Python 2.7.3
Now I need to write programs based on python2.7 version...What would be the shebang line for python2.7
Also, how will I compile using python2.7.
#!/usr/bin/env python """ The first line in this file is the "shebang" line. When you execute a file from the shell, the shell tries to run the file using the command specified on the shebang line. The ! is called the "bang". The # is not called the "she", so sometimes the "shebang" line is also called the "hashbang".
#!/usr/bin/python3 is a shebang line. A shebang line defines where the interpreter is located. In this case, the python3 interpreter is located in /usr/bin/python3 . A shebang line could also be a bash , ruby , perl or any other scripting languages' interpreter, for example: #!/bin/bash .
Just as a tip, you should always do #!/usr/bin/env python2 or #!/usr/bin/env python3. You should always make your Python scripts use a specific version of the interpreter rather than putting just 'python'.
Shebang will be:
#!/usr/bin/env python2.7
I'm not sure why you want to compile Python files (Python will do it automatically when you import them).
If you really want to:
python2.7 -m compileall .
This command will compile .py files in the current directory to .pyc:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With