How Do I Manage Python Virtual Environmental With Multiple Python Versions.

Published on Feb. 19, 2023 | Tags: Python virtualenv dev tools

Recently, no I've been working with different python versions for different projects at work. So far I used pyenv and pyenv-virtualenv with variously degrees of success. However, it become cumbersome quickly managing different python versions, tools that only work with a single python installation at a time and at some point something stopped working and got tired of it.


So I went back to a simpler solution. I decides I would use the official python installer for kac os from python.org. Then, I can use virtualenv. I installed it on a virtual environmental using the built-in venv. Why use virtualenv? Can work with any python version you tell it to,


Then, with the clever use of a couple of shell functions and some aliases had it all pretty much automated.


alias mkv='virtualenv .venv && source ./.venv/bin/activate'

Having the virtualenv in the same directory as tye project, node_modules style, and working with a virtual environment which makes a lot of the other tools work much nicer.


You can checking out my dotfiles for more details.


Ferran Jovell