related but how to do change switch from within python: Is eval $(opam env --switch={switch} --set-switch) equivalent to opam switch set switch? and What is the difference between eval $(opam env --switch={switch} --set-switch) and opam switch set SWITCH? - Stack Overflow