Python 3 installation with nix puzzled PATH

Python 3 installation with nix puzzled PATH … here is a solution to the problem.

Python 3 installation with nix puzzled PATH

I installed Python 3.6 on Debian 9

nix-env -i python3-3.6.2

But now my python interpreter has changed from default Python 2.7 to this Python 3.6.2:

which python
/home/user/.nix-profile/bin/python

This can break a lot of things. How do I install Python 3.6 without replacing the standard Python interpreter?

Solution

That’s right, python3 on Nixpkgs provides a python executable. The root cause is that user-installed programs hide system-wide programs (see your PATH envvar).

You should also install python2 and solve the priority override problem of python executables.

But you might be interested in nix-shell -p python3, which uses python3 to create a temporary environment and leaves python 2 elsewhere.

Related Problems and Solutions