python path for root user broken

I was trying to install xgboost, one of the instructions asked me to run the command

sudo python setup.py install

I got an error saying numpy package not found. I googled the issue and ran the following commans

which python

throws /home/somename/anaconda3/bin AND

sudo su
which python

throws /usr/bin/python

I realized the issue that root doesn't points to the same location. In my efforts to change PYTHONPATH so that both normal user and root points to the same path, I ran the following command without understanding what it actually does.

sudo ln -sf /home/somename/anaconda3/bin /usr/bin/python

after running this command I ran the following commands

sudo su
python

it gives an error, The program 'python' can be found in the following packages: * python-minimal * python3 Try: apt install

I further read about symbolic link and what -sf attribute did, it basically deleted the python executable located at /usr/bin is what I think.

I now want to run python as root user and still find a solution for it to point to python executable located in /home/somename/anaconda3/bin so that my xgboost also installs.

echo $PATH

gives, /home/somename/anaconda3/bin:/home/somename/bin:/home/somename/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:usr/bin/python:/snap/bin

sudo env | grep PATH

gives, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

I also understand my basic understanding of the terms PATH and PYTHONPATH may be flawed. But I really to need to get this working.

Thanks in advance.

pythonpythonpath

Answers

comments powered by Disqus