pythonpyenv

pyenv - how to get more info re: "system", including version


I'm on MacOS, and I have latest python installed via brew. A few months ago, I started using pyenv to be able to switch between latest python and a project that was fixed at python v3.8. I think I got it all set up but I'm confused. pyenv refuses to show me information about system:

$ pyenv versions
* system (set by /Users/<user>/.pyenv/version)
  3.8.6

$ pyenv version system
system (set by /Users/<user>/.pyenv/version)

$ cat ~/.pyenv/version
system

How do I get pyenv to show me the version and/or location of system?? Obviously, I can get info about system python when it's the one in use, but why doesn't pyenv show anything about it? Showing info about the current config seems like basic functionality for a config management tool.

By comparison, when I run apt list --installed, it shows me what's installed, whether installed by me or bundled with the OS. It doesn't just show a placeholder for things installed by the system.

So I'm frustrated that pyenv is doing this.

Edit: Wow, nvm is the same way. How? Why? Why do these tools have a built-in disregard for the system config?


Solution

  • Pyenv is a shim tool. It's used to intercept calls to python and pip and transparently give the correct binaries for these commands. When you call python -m some_module, pyenv will find the correct python binary that makes sense for that call, either because it's locally set by a .python-version file or set by the current shell using pyenv shell or pyenv activate commands.

    Pyenv tries to not mess up with current python installations, because the environment system may use these tools, and should keep using whatever version they are already using. Thus, it simply packs the currently existing binaries as "system" and does not touch it, so that the existing system prior to installing pyenv keeps working as it was before.

    As a best practice, I recommend you to create a new environment and set it with pyenv global to something different of system (e.g. pyenv install 3.9.10 && pyenv virtualenv 3.9.10 myglobal && pyenv global myglobal) -- so that your default application python is different from the operating system python, and thus you can't mess with the system; just leave system as is. If you want to check what system is, you can activate it and call it normally, pyenv activate system ; python --version will show the version, but it's not something you should be doing in the first place, so pyenv doesn't support it.