I have uninstall anaconda2. but now when I run Python command in terminal it says "bash: /home/user/anaconda2/python: No such file or directory" now how can I set to Python when I have python 2.7 in "/usr/lib" .
4 Answers
I'm assuming that when you installed anaconda 2, you manually set the PYTHONPATH
environment variable, by putting something like
PYTHONPATH=/home/user/anaconda2/python
export PYTHONPATH
in your .bash_profile
or .bash_rc
.
But since you deleted the /home/user/anacanda2/
directory, that path no longer exists.
Thus you want to change PYTHONPATH
to point to the executable in /usr/lib
, by changing the above to
PYTHONPATH=/usr/lib/my_python_distribution
export PYTHON
execute the command:
echo $PATH
root1@master:/usr/lib/python2.7$ echo $PATH /home/root1/anaconda3/bin:/home/root1/NAI/Execution/HDE/x86_64.linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/root1/java/jdk1.8.0_74/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/root1/NAI/hadoop-2.7.3/bin
Remove your anaconda3 from your path variable that is
/home/root1/anaconda3/bin:
Again set PATH variable with remaining information like below
export PATH=/home/root1/NAI/Execution/HDE/x86_64.linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/root1/java/jdk1.8.0_74/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/root1/NAI/hadoop-2.7.3/bin
Execute python command and should redirect to your python interpreter
root1@master:/usr/lib/python2.7$ python Python 2.7.14 (default, Sep 18 2017, 00:00:00) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
Add following top your ~/.bashrc and it should work
PYTHONPATH="path1:path2:$PYTHONPATH"
export PYTHONPATH
Replace path1, path2 with full path to your work directories
If you are just looking for python interpreter and want it to include in your script then just find the python binary path by the command which python
and use that path.
For troubleshooting and setting PYTHONPATH
see this link:
https://stackoverflow.com/questions/18247333/python-pythonpath-in-linux
~/.bashrc
)? You probably just need to remove these, rather than set any additional path.