Ubuntu – How to get Ubuntu to use Anaconda’s python instead of the standard /usr/lib/python…


I installed Anaconda using instructions provided on the main website, which are similar to those that can be seen here: How to install Anaconda on Ubuntu?

However, I found that I had to manually change PATH using an export command in ~/.profile (as per official Ubuntu instructions: https://help.ubuntu.com/community/EnvironmentVariables) to get the system to know about ~/anaconda/bin:

export PATH="/usr/local/texlive/2014/bin/x86_64-linux:$PATH"
export PATH="~/anaconda/bin:$PATH"

Already, this was surprising because Anaconda should have been able to sort things out correctly itself during installation.

Now, another issue I am having is that when I run python in terminal, it defaults to using the Python in /usr/lib/python…, rather than ~/anaconda/bin/python.

How do I fix this?

Best Answer

  • The tilde (~) character is not expanded when enclosed in quotes (even double quotes, which allow most other filename expansions). You should replace ~ by $HOME in the PATH export:

    export PATH="/usr/local/texlive/2014/bin/x86_64-linux:$PATH"
    export PATH="$HOME/anaconda/bin:$PATH"
  • Related Question