Ubuntu – Python 3 default interpreter

anacondapython3

I've installed Anaconda (with Python 3.5.2) and although while using IPython/PyCharm (after setting it to use Anaconda) I have access to all the packages, while using Python 3 through the terminal it refers to the python3.5.1 that comes with Ubuntu and it doesn't recognize any package.

I've set my path as explained here

echo $PATH:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/myname/anaconda3/bin

How to solve this?

Best Answer

It looks like you were setting your PATH using

export PATH=$PATH:/home/ofirarzi/anaconda3/bin

Unfortunately, this means that /usr/bin/python3 comes first before //home/ofirarzi/anaconda3/bin/python3, so your system Python 3 gets called instead of Anaconda's Python 3 when you run python3 in the terminal. To fix this, you just need to reverse the order of the components of PATH, i.e., in your ~/.profile, do

export PATH=/home/ofirarzi/anaconda3/bin:$PATH

Then do source ~/.profile and try python3 again. For the new PATH to take effect in the terminal in the future without manually sourcing ~/.profile every time, you have to log out and then log in again or reboot.

Note that the way I have exported PATH is also described by Anaconda's documentation at https://docs.continuum.io/anaconda/install#linux-install.