good ol' nasty jupyter notebooks support this:
%pip install foo~=1.5
%pip install bar~=1.7
import foo
import bar %pip install foo~=1.5
%pip install bar~=1.7
import foo
import bar