7

I have just installed the Anaconda (for ipython notebook -- wanted to run some pandas programme). It is installed successfully but the problem here is whenever I type which python, it is always using a default python as /usr/bin/python

It will be great if someone can tell me how to setup the anaconda python as a default python. I am noob here till now I have just installed the anaconda in the default path as following ~/anaconda3.

Thanks in advance.

9

I have the same setup as you desire. In my case the anaconda installer added an entry in my ~/.bashrc file. I don't know why yours did not. So to get to do what you want, add this to your ~/.bashrc file:

export PATH="/home/yash/anaconda3/bin:$PATH"

You need to refresh your env variables after this by opening a new terminal or using source ~/.bashrc

With this:

$ which python
/home/yash/anaconda3/bin/python

And python -v returns: anaconda

To get back to the former default, I comment out the entry setting the pathbin the .bashrc file and get these results:

$ which python
/usr/bin/python
$ python -v
python 2.7.*
  • 2
    That's fine, ofc. But I'd suggest using environments, that way you can create as many python envs as you want and switch between them using source activate/deactivate: conda.io/docs/using/envs.html – Samuel Santana Feb 24 '17 at 21:17
  • I have the above added to ~/.bashrc however which python does not return the anaconda3 version..... do I need to reboot for it to take effect? Just installed anaconda. – user391339 Feb 23 '18 at 19:37
  • # added by Anaconda3 installer export PATH="/home/d/anaconda3/bin:$PATH" – user391339 Feb 23 '18 at 19:38
  • 1
    Ah, I got it. You need to refresh the environment variables either by re-opening a new terminal or typing source ~/.bashrc – user391339 Feb 23 '18 at 19:40
2

Instead of adding the entry in ~/.bashrc add the entry in ~/.profile or ~/.bash_profile as it is a path and not an alias. Also, adding the path in bashrc may slower the terminal unnecessarily. To know the detailed meaning of ~/.bashrc and it's difference with the profile visit this link.

0

After you installed Anaconda, just run

source ~/.bashrc

If you open the .bashrc file you can see it added Anaconda python to environment variable.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.