Tuesday, March 15, 2022

[SOLVED] anaconda not recognised after updating environment variable linux

Issue

I have installed anaconda on a linux red hat system by running the following command (on a airgapped remote system where I don't have sudo privileges or internet access).

$bash Anaconda3-5.1.0.Linux-x86_64.sh

This has installed anaconda in the directory /home/myuser/anaconda3/

The .bashrc file reads:

#added by Anaconda3 installer
. /opt/projectname/bin/setenv.sh
export PATH="/home/myuser/anaconda3/bin:$PATH"

When I run $conda or $jupyter notebook, I get command not found.

$python launches an old version of python which is not linked to anaconda.

If I run:

$bash jupyter notebook 

from /home/myuser/anaconda3/bin/

I get:

jupyter: line 4: import: command not found
jupyter: line 5: import: command not found
etc...

How can I get the system to run the correct version of python and successfully launch jupyter notebook?

EDIT: is the problem here that anaconda was installed in /home/myuser rather than /usr/x or /opt/x?


Solution

Try this on terminal

source /home/myuser/anaconda3/bin/activate

This will activate your anaconda python installation. (base) should appear in your terminal.

Now jupyter notebook should work.

Note : I did not append anaconda3/bin to the PATH variable as I wanted to keep my original python installation as default. I activate anaconda3 using the above command everytime I needed it.



Answered By - impopularGuy
Answer Checked By - Timothy Miller (WPSolving Admin)