0

I am trying to upgrade Python 3 to the latest version on Debian Jessie, but I would like to keep system-installed Python 2 intact. By default, python command executes Python v2, and python3 command executes Python v3.

python --version
Python 2.7.9
python3 --version
Python 3.4.2

If I install and switch to e.g. Python 3.6.3 using pyenv:

pyenv install 3.6.3
pyenv global 3.6.3

Now both python and python3 point to v3.6.3.

python --version
Python 3.6.3
python3 --version
Python 3.6.3

How can I achieve that only python3 points to newly installed version, and python keeps pointing to system installed Python v2?

1 Answers1

0

the problem here is that you executed pyenv global $python-version and this define a final context for that python execution.

Eventually you are supposed to pyenv global 2.7.9 to switch back to normal. but if it's only about having default python versions, you simply need to disable pyenv. echo "" > /home/$USER/.pyenv/version

This requires that you have actually the right versions installed at a system level ( with sudo apt-get install python3.6 ) .

You could also pay with your $PATH by adding an extra location that calls /bin/python2 instead as a symlink but I am really afraid of side effects around LD_LIBRARY_PATH especially with certain additional modules but I didn't tested or dig enough on side effects.

leldo
  • 111
  • 3
  • Modifying $PATH is a possible solution, but I was hoping it's possible to do it within pyenv. BTW, I can't install Python 3.6 using apt on Jessie, I wouldn't use pyenv if I could. – Nikša Baldun Jan 26 '18 at 16:37
  • you might want to check https://unix.stackexchange.com/questions/332641/how-to-install-python-3-6 Possibly conpiling it ( the second solution would be mutch better than pyenv – leldo Jan 26 '18 at 17:02
  • Yes, in my case it seems pyenv is a suboptimal solution. I'll try your suggestion. – Nikša Baldun Jan 26 '18 at 20:08
  • I ended up compiling from source and manually symlinking python3 to the new binary. Not ideal, but it gets the job done. – Nikša Baldun Jan 29 '18 at 21:54
  • Good to know ! It can really become messy but I think you make the right choice – leldo Jan 30 '18 at 06:37