4

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" .

1
  • 2
    When you installed anaconda2, did you add any PYTHONPATH directives to your startup file(s) (such as your ~/.bashrc)? You probably just need to remove these, rather than set any additional path. Dec 31, 2015 at 21:53

4 Answers 4

5

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
3
  1. 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
    
  2. Remove your anaconda3 from your path variable that is

    /home/root1/anaconda3/bin:
    
  3. 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
    
  4. 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.
    >>> 
    
1

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

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .