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.


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.