5

what is best-practice for changing the default global python interpreter on my fresh debian-based linux node to python3.x?

When I create a fresh Debian or Ubuntu VM, one of the first things I do is use apt to install python3-dev & python3-pip, and sometimes either echo "alias python=python3" >> ~/.bashrc so I don't need to do it again, or even sudo su && echo "alias python=python3" >> /etc/profile.d/00-aliases.sh && exit when I need to make a daemon user like /home/SQLserviceacct/ or /home/Neo4jworker/.

The result is often havoc for potential programs or humans who make shell calls to python and then use any other default python-related environment variables. When things like $PYTHONPATH get assigned out of context, problems arise. I think virtualenvis probably involved somehow.

  • See this https://unix.stackexchange.com/a/496488/255251 – Prvt_Yadav Feb 11 '19 at 05:57
  • Also https://askubuntu.com/a/321000/296757 – undercat Feb 11 '19 at 09:54
  • Well so the first one says use update-alternatives which I'm starting to think might be, and the 2nd one just says to alias it like I'm already doing. I'm just wondering if there's anything more comprehensive I can do? – Rob Truxal Feb 11 '19 at 16:43

1 Answers1

1

One possibility would be to link /usr/bin/python to /usr/bin/python3, this way the change will be system wide:

ln -s /usr/bin/python3 /usr/bin/python

Panki
  • 6,664
  • I HATE PYTHON MORE THAN WORDS CAN DESCRIBE IT IS SUCH A PIECE OF **** THANKS THIS IS THE ONLY ANSWER THAT WORKS – Anthony Apr 05 '22 at 21:13
  • @Anthony that's not an issue with python, but with your installation/system setup. – Panki Apr 06 '22 at 16:47