This question already has an answer here:
I tried installing Anaconda to get many python packages at once but had some issues with python IDLE where it said No package found
so had to manually set the path in ~/.bashrc
.
Once I set the path in ~/.bashrc
the IMPORT ERROR
in python IDLE was solved but I'm unable to use commands on terminal now.
I'm getting this error all the time.
sid@sids-ubuntu:~$ ls
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
sid@sids-ubuntu:~$ sudo
Command 'sudo' is available in '/usr/bin/sudo'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
sudo: command not found
sid@sids-ubuntu:~$ mkdir aa
Command 'mkdir' is available in '/bin/mkdir'
The command could not be located because '/bin' is not included in the PATH environment variable.
mkdir: command not found
I did export PATH=/usr/bin:/bin
to find out my $PATH
and content of /etc/environment
. It seems both are different.
sid@sids-ubuntu:~$ export PATH=/usr/bin:/bin
sid@sids-ubuntu:~$ echo $PATH
/usr/bin:/bin
sid@sids-ubuntu:~$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
Doesn't Ubuntu look for $PATH
in /etc/environment
?
If yes, what could be the reason my $PATH
is different from /etc/environment
? and please help me fix it!
If not, where does Ubuntu look for $PATH
? please help me fix it!
When adding some directory to
PATH
it's good idea not to overwrite previous value, just append desired directory (e.g.$HOME/bin
), in your~/.bashrc
add at the end line (and remove any previous tampering withPATH
)and run:
(or just open new session of terminal).
Be aware that your /etc/environment is only re-read at reboot.
When you want to change your path, be sure to include the existing part as well. To do that, add $PATH in the new path definition.
Looking at your problems, adding the $PATH in your ~/.bashrc should do the trick. If not, open a new terminal and show us the output of
PATH is an environment variable, and therefore it is not looked up in any file.
There are several files which are sourced when bash is invoked (see the section named INVOCATION in the bash man page), and while sourcing these files, the environment variable PATH can be set, respectively manipulated. Note that
.bashrc
is not always processed; please read the bash man-page carefully to understand, which files are included under which condition.