I tried to install anaconda on my Ubuntu VM (following this), but for some reason the installation skipped on adding anaconda to the PATH variable.
I followed instructions here and it somewhat helped. Now I have to call:
export PATH=$PATH:/home/myname/anaconda3/bin
every time. It works (for example, if I want to import numpy) , but obviously not comfortable. how can I solve it so it will work from now?
this is the PATH variable –
PATH="$HOME/bin:$PATH:/home/name/anaconda3/bin"
and echo $PATH
returns /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
when I try to import I get –
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
right now, calling echo $PATH
in the in the window where i called source
gives
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ofirarzi/anaconda3/bin:/home/ofirarzi/anaconda3/bin
but in any other window I get
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Best Answer
There are 2 possible solutions:
1. Correct the
$PATH
statement manually:You have made an error in your
~/.profile
file which accounts for anaconda not being in your$PATH
. Your have added here:which is incorrect as the conditional statement tests for the directory
$HOME/bin
and if this is not present the extra$PATH
will be ignored. In your case I suspect you do not have a$HOME/bin
...Try the following instead (leaving preceding lines of
~/.profile
untouched):Note that the new anaconda
$PATH
is prepended rather than appended as explained in this post. Then test by running the following two commands:And now all should be well, if not:
2. Allow the installer to correct the
$PATH
:If there is still some trouble I note that the anaconda installer offers to make the required changes for you. I installed on Xenial and saw the following offer at the end of installation (the arrows are my addition):
And on my Xenial system typing 'yes' added the following to
~/.bashrc
:So a re-installation of anaconda is another option, allowing the installer to do the hard work :)