3 ms·
In a *nix environment, set the shebang line of the file to point to the precise interpreter you want to use. Any imports that file makes will be from the /usr/
by pcc 17y ago
In a *nix environment, set the shebang line of the file to point to the precise interpreter you want to use. Any imports that file makes will be from the /usr/lib/pythonX.Y for that version of the interpreter. (In order to get the library installed into that path in the first place, it must have been done via that version of the interpreter specifically, so its quite possible to keep 3.x and 2.x versions of the same library quite isolated).
Of course imports can also come from the local dir, via pythonpath and the various manipulations thereof (buildout, virtualenvs etc), so there are a few degrees of freedom via which to manage things.
May be worth pointing out that a file and all its imports will only be running under one interpreter, so a file running on 3.x (via shebang line, say), will not be able to use a 2.x library (even if placed in the correct path) where the code of that library is fundamentally not 3.x compatible.