I was trying to install this on fedora 40 using the venv method and the conda method - seems that pip decides to install a version of stable-baselines3 that pulls in gym in version 0.21 that is not installable with recent pythons (cf. openai/gym#3176)
I have fixed this locally by forcing stable-baselines3 to version 2.2.1 (no clue if this is a good version) but maybe that is something you might need to look at