Best way to install python?
If I want to always be able to have the latest/greatest python, and NOT have it collide with default system installation of python (on ubuntu or RHEL), what's the best way to do this? I dislike having the system default because it always lags way behind.
If I just install from source and put it in /usr/local, will it start putting libraries into some of the system default's lib directories? What about when the next version comes out? Should I just install it at /usr/local/python36 or something?
Also, I want to have various projects and make use of virtualenv, from my understanding it makes a copy of the python binary at that time, how will this work when I upgrade python?
Posted Apr 7, 2016, 6:07 PM UTC
Have a look at pyenv. It lets you manage and switch between multiple versions of Python.
As long as you don't remove old versions when upgrading, existing virtual environments won't break.
This looks like it should be part of the equation here. I see that pyenv puts different python installs into its own location. I'm assuming as you do pip install, it will put the packages into that directory structure too.
I guess we'd also want to layer virtualenv on top of that.
It also has pyenv-virtualenv and pyenv-virtualenvwrapper to make working with both of those tools, in conjunction with pyenv, easier.
virtualenv, in the end, you can just issue-
or with pyenv's virtualenv plugin installed-
To be sure you're creating an env for a specific version you have installed.