I found that when I just type python in the command line, I got Python 2.7.9. And when I type module load python and then python again, it gives me Python 2.7.12 :: Anaconda custom (64-bit), which is the version I need. Can anyone explain how it happens? And what can I do to make version 2.7.12 default when I simply type 'python'?
2 Answers
firstly what do you mean "module load python" ?
another point, changing $PATH variable, you can set default python version.When you type 'python',terminal searches it in $PATH and few various directory.Therefore remove path which refers old version in $PATH ,then add new path which refer to Python 2.7.12,For this use this
Place export declaration in ~/.bashrc.
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/u:$PATH
But the above solution may not work,thus use this simple way alias.Like below
Place this into ~/.bashrc file
alias python=Python 2.7.12
2 Comments
The module command helps to activate/deactivate specific software version in your running shell. This command interprets scripts that are called modulefiles containing some environment definition to enable a specific version of a software, like for instance by altering the PATH variable.
You can learn what a modulefile does by displaying its content, in your situation:
$ module display python
The environment setup done by the module command is not persistent and it should be renewed if you start a new shell session. To get python 2.7.12 by default, you should edit your shell configuration file to automatically load this modulefile when shell is started.
modulecommand coming from? That's not part of Python itself, so I can't tell you how it's working. Can you elaborate a bit on what OS and Python distribution you're using?