4 ms·
u can use virtual environments for that
by Yajirobe 6y ago
u can use virtual environments for that
- giancarlostoro 6y agoIn the case of 'Python Virtual Environments' you'd still have to install another version of Python which is non-trivial with Debian based systems without causing some sort of collision, unless you download the binaries to /usr/ or other bin location as suggested.
- TYPE_FASTER 6y agoI like to use pyenv for this purpose, as it "virtualizes" Python versions by installing them locally as you mention. Then you just point each virtualenv at the Python binary for the version installed via pyenv. pyenv + virtualenv + virtualenvwrapper have greatly reduced Python dependency issues for me.
- giancarlostoro 6y agoA bunch of programming languages do a little bit similar like Node has Node Version Manager or nvm, I think Go has GVM, Rust just has Rust Up, they usually install in your home folder and let you swap between versions globally, I've yet to have to do this as I usually spin up a VM if I know I'm going to need to deploy to a very specific version of Debian / Ubuntu, a virtual environment might not match behavior on the actual target system but a VM definitely will.
- fidelramos 6y ago+1 to pyenv. And it's even better if you combine it with pipenv [1]: pipenv manages dependencies its own file (Pipfile) which can also specify the required Python version. Pipenv integrates with pyenv so if the required Python version is not available it will offer to download and install it. Tldr; with pyenv and pipenv installing a Python project is just "pipenv install". [1] https://pipenv.pypa.io/en/latest/ https://pipenv.pypa.io/en/latest/
- strbean 6y agoI would strongly recommend taking a look at Poetry as an alternative to Pipenv. Pipenv is honestly a nightmare.
- kstrauser 6y agoI regret I can only upvote this once. Pipenv still gets press, but I'm not sure why. Every senior dev I know switched to Poetry long ago.
- fidelramos 6y agoI have been using pipenv only on a couple of projects and for a few months, but it has been an improvement over pip and virtualenv. Why do you say Pipenv is a nightmare? Have you had bad experiences with it?
- beagle3 6y agoEspecially in the case of a python virtual environment, "conda" solves everything ultra cleanly (regardless of whether it's debian, fedore, arch or Windows and probably macOS too though I didn't try). It provides any version of Python, regardless of what your base system has (or lacks). It also provides an isolated gcc and many other packages; and you can still "pip install" inside it if the package you need is not conda-native, and conda will track it just as well. Conda is really underappreciated.
- freeone3000 6y agoIt's totally trivial. ubuntu 18.04 has packages for python3.7 and python3.8 which install to /usr/bin/python3.7 and /usr/bin/python3.8, leaving /usr/bin/python3 pointing to /usr/bin/python3.6. So, you'd type: `sudo apt -y install python3.7` Then: `mkvirtualenv --python $(which python3.7)` It really is that easy.
- amelius 6y agoPerhaps virtual environments should be the default on Linux distributions?