nimaxin
nimaxin

Reputation: 118

How to install and manage multiple python versions globally using Rye?

I'm trying to use Rye to manage multiple Python versions on my system globally. I want to avoid using Pyenv or similar tools, as I know they work, but I prefer to use Rye for this task. I aim to handle Python versions at the system level, not for a specific environment or project.

Could someone please provide a detailed guide on how to:

  1. Install different Python versions globally using Rye.

  2. Set a specific Python version as the global default.

  3. verify the installed versions and the global version set.

Upvotes: 3

Views: 285

Answers (1)

willwrighteng
willwrighteng

Reputation: 2994

the current rye install will set a default shim as your global python and python3 -- implemented by adding the following line to you shell rc file:

source "$HOME/.rye/env"

I will implement a specific version of python using the rye pin command

for example:

mkdir tmp && cd tmp
rye init
rye pin 3.13

you can see which shims are installed in the ~/.rye/py/ directory

set global python version

in order to set a specific shim as your default, use the rye config --set command to modify your ~/.rye/config.toml file

for example:

python --version
# Python 3.12.8
rye config --set [email protected]
python --version
# Python 3.13.1

references

aside

installing modules globally requires that you add the shim bin path to your PATH env var... there's probably a more elegant way of doing this but this is my current line within my .zshrc

export PATH="$HOME/.rye/py/[email protected]/bin:$PATH"

Upvotes: 0

Related Questions