0

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
  • 1
    Where 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? Commented Jul 20, 2017 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. Commented Jul 29, 2017 at 5:36

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

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.
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)
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.