my OS (Ubuntu 14.04) uses an older version 2.7.6 of Python as /usr/bin/python
which points to /usr/bin/python2.7
I installed a new version 2.7.9 of python as /usr/local/bin/python2.7
.
In my own shell,
how can I make all python scripts with shebang to use the new python? Does use
#!/usr/bin/env python
as shebang solve the problem? How shall I make it work?Can I also make the command
python
be the new one?
while letting my OS still use its original older one?
/usr/local/bin
to the beginning of their search path so that they can run newer versions of system programs. If this is OK with you, runsudo ln -s /usr/local/bin/python2.7 /usr/local/bin/python
, then edit your own~/.bash_profile
to include a line that saysPATH=/usr/local/bin:$PATH
. Logout, login again. Runpython --version
to verify.