pyenv Notes
This article documents the practice and experience of managing Python versions using `pyenv` in an Ubuntu 24.04 environment. The motivation was that while building the MongoDB source code, the official documentation required Python 3.10+, but the system's default version 3.12.3 caused the build to fail due to API incompatibility. Since modifying the source code was not an option, the decision was made to use `pyenv` to specifically install a 3.10.x version. The article details the process of automatically installing `pyenv` via a `curl` script and configuring `~/.bashrc`. It also highlights the extremely unfriendly user experience of `pyenv`, specifically noting the lack of progress indicators, minimal information feedback, and the absence of interactive options during installation and build processes. Additionally, addressing the issue where `pip` and `poetry` command-line mirror source configurations failed, the author successfully configured the Tsinghua University or Tencent Cloud mirror addresses to accelerate dependency package downloads by manually creating and editing the `~/.pip/pip.conf` and `~/.config/pypoetry/config.toml` files. The article emphasizes the importance of not arbitrarily modifying the system's pre-installed Python environment and repeatedly warns developers to avoid writing programs that lack user feedback and interactivity. It suggests that readers refer to this configuration method in similar scenarios to avoid potential pitfalls.