Ubuntu – can’t find conda but only when i use sudo

anacondacondapython

I have just install anaconda (python 2.7 version) in /usr/local/bin

I added /usr/local/bin/anaconda2/bin/ to the path.

Now when I run conda from the command prompt it runs fine (but can't install anything without sudo because of the directory it's in).

However when I run the same command with sudo it can't find conda.

Does anyone know why this is?

Without sudo:

$ conda
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command

With sudo:

$ sudo conda
sudo: conda: command not found

Best Answer

Try to call conda with its absolute path :

 sudo /path/to/conda

You probably added conda location to your user $path but not to the sudo account

If this works, you can modify the $path for the root user the same way you did for your user

sudo export PATH=$PATH:/usr/local/bin

EDIT : export doesn't work with sudo, but you can change your path in /etc/sudoers (secure_path)