I use python310 as system default
On all unix and unix-like systems, "system python"
really is part of the system,
so you need to avoid changing it in any way.
Modules in official ports and packages are set up to run with a specific FreeBSD version,
including the system Python (not modified in any way) that comes with that version.
When using
pip to install a module for the system's python version, do it as yourself, not root, and include "
--user" in the pip command, so that the module does
not go into the system python directory, and instead goes into "~/.local/lib/python3.8/site-packages", which you can fool around with as much as you like.
Whatever you install in "~/.local/.../site-packages" will be run by the
system's python
interpreter, but when the system runs a python script
as root, it does not look in there, so cannot be affected by it.
When you run python as yourself, it prefers to load a module from
your local site-packages, if the same module also exists in system site-packages. So it's possible to customize a local module, to get different behaviour when it runs as you (but it has to be for the same python version).
If you need a version of python later than system python, look in freshports;
current latest is '
https://www.freshports.org/lang/python310' (updated a few days ago).
You'll need to install it in a custom location so it does not conflict with system python,
but I don't yet know how to do that on FreeBSD.
On the command line, 'python' must always run system python,
so you run a non-system python by giving the whole path to its executable,
or by giving its executable another name so that you can put it in the path,
or by putting a symlink or a script that calls it in the path.
(The other name can be anything you like, as long as it doesn't conflict with something else.)
On Linux, I found that I couldn't simply copy the system python to another place and run it separately,
as it seemed to be hard-coded to use the system's "/lib/pythonN.N" directory.
Maybe it's like that in all unix-type OSes -- in Windows it's not.
Apart from that, python is very flexible about how and where you run it.
On Linux I used
pyenv to install an independent python interpreter (any version);
it downloads the source and compiles it to run from any location that you specify.