0

I'm not familiar with Linux and I am just trying to change my Python dir from one to another. I read from another post that if you do:

unlink pathA
ln -s pathA pathB

It will change to pathB. So that's what I did:

unlink /Users/apple/opt/anaconda3/bin/python
ln -s /usr/bin/python /Users/apple/opt/anaconda3/bin/python 

But then when I try to change it back, I did it again, this time unlink-ing the other path:

unlink /usr/bin/python

Now that I know what exactly does unlink do... I realized I did something very bad. This has caused all of my paths being removed. Now whenever I call Python it throws me

python: command not found

And whenever I call pip it throws me

-bash: /Users/apple/opt/anaconda3/bin/pip: /Users/apple/opt/anaconda3/bin/python: bad interpreter: No such file or directory

I know this might be a dumb question but I am just a starter. I really appreciate your help.

Zeta Lee
  • 1
  • 1
  • You need to provide a bit more information here. Unlink is not working on directories. So either `unlink pathA` returned with an error or pathA was just a symbolic link to where ever your python is. If `unlink pathA`actually worked then `ln - s pathA pathB`has to fail, as pathA no longer exists. – Lutz Sep 16 '22 at 07:49
  • details are updated to the original post, thanks for the headup – Zeta Lee Sep 16 '22 at 15:04
  • Your first pair of commands make no sense. The parameter order of `ln` is the same as `cp`.... `cp src dest` creates `dest` by copying `src`. `ln src dest` does the same thing, creating `dest`, but this time by hardlinking to `src`. `ln -s src dest` does the same thing, creating `dest`, but this time it is a symbolic link to `src`. It might make sense to `rm dest` before doing any of those, but it would make no sense at all to `rm src` which is what you have. – Ben Voigt Sep 16 '22 at 15:39
  • `unlink /Users/apple/opt/anaconda3/bin/python` is not what you want to/should do. Rather what you should do is to change the PATH-variable. I assume you have python installed under `/Users/apple/opt/anaconda3/` what you could do is to set the path variable to first point to bin folder there: `export PATH=/Users/apple/opt/anaconda3/bin/:${PATH}`. After that the system will first search in the anaconda/bin folder for executables and then where ever it did search before. Also what system do you have `/User/`is a rather unusual place for home folder in linux. – Lutz Sep 19 '22 at 10:16

1 Answers1

0

You could search where your python installation is with find / -name python 2>/dev/null. This will give you the path to python, the set the python environment variable and there you go. Unless you have something else in mind.
Here you can also find extra info: Add to python path mac os x

Petronella
  • 2,327
  • 1
  • 15
  • 24