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'?

- 771
- 7
- 21

- 1
- 2
-
1Where is the `module` command 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? – Blckknght Jul 20 '17 at 22:59
-
I am working on a shared host (computer center). It should be a Linux system. And from what I learned from the web, module seems to be something that control different versions of software. I just use it on the command line, and not sure what it really is. – Hui Kong Jul 29 '17 at 05:36
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

- 376
- 2
- 10
-
Module is a command that can control different versions of software. I was told by others to use it on the command line, and not sure what it really is. – Hui Kong Jul 29 '17 at 05:40
-
I think what you said is the correct answer, and it works.on personal computer. But I don't have permission to change the .bashrc files on the host. I am still searching for other solutions (maybe ask people in charge to do that) – Hui Kong Jul 29 '17 at 05:44
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.

- 771
- 7
- 21