set default python version when run the program as executable ./xxx.py - on linux -


i run python directly executable file ./xxx.py

however, when run this, automatically use python 2.7 instead of python 3.

how use python 3 run executable python file?

in case:

./magane.py shell 

it give me

python 2.7.9 (default, apr  2 2015, 15:33:21)  [gcc 4.9.2] on linux2 type "help", "copyright", "credits" or "license" more information. (interactiveconsole) >>>  

but have this:

python3 manage.py shell /home/cliu/.local/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py:57: runtimewarning: sqlite received naive datetime (2015-05-31 15:24:46.785297) while time zone support active.   runtimewarning)  python 3.4.3 (default, mar 26 2015, 22:03:40)  type "copyright", "credits" or "license" more information.  ipython 2.3.0 -- enhanced interactive python. ?         -> introduction , overview of ipython's features. %quickref -> quick reference.      -> python's own system. object?   -> details 'object', use 'object??' details.  in [1]:  

where python3 uses ipython.

to tell python version use , make executable on linux have following steps:

add #! python script

#!/usr/bin/env python3 

add permissions run it

chmod +x xxx.py 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -