The go-to resource for upgrading Python, Django, Flask, and your dependencies.

Managing Python 3.11, 3.12, and 3.13 Simultaneously with mise on Windows WSL2


When developing on Windows WSL2 (Ubuntu), you’ll often need to work with multiple Python versions simultaneously—such as 3.11 for stability, 3.12 for new features, and 3.13 for the latest developments—without conflicts between them. Mise is a Rust-based tool that helps manage language versions; it provides precompiled binaries, supports automatic virtual environments, and uses .tool-versions files for project-specific settings, similar to pyenv or asdf but with a focus on performance. This guide is part of our mise series: 1: Migrating from pyenv, 2: asdf on Ubuntu, 3: Benchmarks, 4: Common fixes. Here, we cover mise installation, multi-version management, and WSL2-specific considerations.

Why consider mise for Multi-Python on WSL2?\n\nMise offers several features useful for managing Python versions:\n\n- Precompiled Pythons: Avoids compilation dependencies; installations typically complete in under a minute, unlike compiling from source which can take 10+ minutes.\n- Simultaneous Use: Commands like python3.11, python3.12, and python3.13 coexist without interference.\n- Project Isolation: Per-project .tool-versions files enable automatic switching when entering directories.\n- WSL2 Compatibility: Works natively on Linux, integrates with VS Code’s Remote-WSL extension.\n- uv Integration: Pairs well with uv for faster virtual environments and package management.\n\nWhile system package managers like apt provide convenience for single versions, they often limit flexibility for multiple concurrent installations. Mise addresses this, though it requires initial setup and may not suit environments needing strict reproducibility without additional configuration.

Step 1: Install mise in WSL2\n\nWe’ll install mise using its official script:\n\nbash\n$ curl https://mise.run | sh\n

Next, add mise activation to your shell configuration file ~/.bashrc (or ~/.zshrc for zsh):\n\nbash\n$ echo 'eval \"$(mise activate bash)\"' >> ~/.bashrc # Use 'mise activate zsh' for zshrc\n$ exec bash # Reload the shell\n

Verify the installation:\n\nbash\n$ mise --version\n

Step 2: Install Python 3.11, 3.12, 3.13\n\nFirst, let’s see which versions are available that match our criteria:\n\nbash\n$ mise ls-remote python | grep -E '3.(1[123]\\.|13\\.)'\n\n\nNow install the ones we need (mise will fetch the latest patch for 3.11 and 3.12, specific for 3.13.0):\n\nbash\n$ mise install python@3.11\n$ mise install python@3.12\n$ mise install python@3.13.0\n\n\nEach installation takes around 30 seconds thanks to precompiled binaries—no additional build dependencies required.

Step 3: Set Global Default with Fallbacks\n\nMise allows setting a global default Python with fallbacks for specific versions. This way, python uses 3.13 by default, while python3.11 etc. use their versions:\n\nbash\n$ mise use -g python@3.13 python@3.12 python@3.11\n\n\nNow:\n- python points to 3.13\n- python3.12 to 3.12 (specific commands work)\n- Falls back if a version is unavailable\n\nLet’s verify:\n\nbash\n$ python --version # Should show Python 3.13.0\n$ python3.11 --version\n$ which python # ~/.local/share/mise/installs/python/3.13.0/bin/python\n

Step 4: Per-Project Management with .tool-versions\n\nTo see mise in action for projects, create a directory and set a project-specific version. Mise detects .tool-versions and switches automatically via shims:\n\nbash\n$ mkdir myproj311 && cd myproj311\n$ echo \"python 3.11\" > .tool-versions\n$ mise install # Installs 3.11 if missing\n$ python --version # Now uses 3.11\n\n\nNavigate between projects, and mise adjusts seamlessly.

Step 5: Virtual Environments with mise\n\nMise can automate virtual environment creation and activation. Create a mise.toml in your project root for configuration:\n\nFor explicit venv path:\n\ntoml\n[tools]\npython = \"3.12\"\n\n[env]\nVIRTUAL_ENV = { value = \"{{ tools.python.venv_path }}\", if_exists = true }\n\n\nOr to auto-create:\n\ntoml\n[env]\n_.python.venv = { path = \".venv\", create = true }\n\n\nRun mise shell to activate the environment.\n\nFor even faster venvs/pip, install uv globally:\n\nbash\n$ mise use -g uv@latest\n

WSL2-Specific Tips\n\nWhen using mise in WSL2, keep these points in mind:\n\n- Access from Windows: Python installations are at \\\\wsl$\\Ubuntu\\home\\$USER\\.local\\share\\mise\\... in File Explorer.\n- VS Code Integration: Install the Remote-WSL extension, open your project folder in WSL—mise shims are automatically detected.\n- PATH Considerations: Rarely needed, but if accessing from Windows, add /home/$USER/.local/bin to your Windows PATH.\n- Alternative Terminals: Prefer native WSL terminal over Git Bash or MSYS2 for mise compatibility.

Troubleshooting\n\nHere are solutions for common issues you might encounter:\n\n- Command not found after install: Run mise doctor to diagnose, then reload your shell or restart the terminal.\n- Slow or failed installs: Set a GitHub personal access token: export MISE_GITHUB_TOKEN=ghp_... (generate at github.com/settings/tokens).\n- WSL PATH problems: Check echo $PATH; run mise reshim python to regenerate shims.\n- Compatibility on older CPUs: mise settings set python.precompiled_arch x86_64.\n- Virtual env not activating: Ensure mise activate is in your shell profile; use mise shell manually.\n- Version not switching: Verify .tool-versions syntax and run mise reshim.\n\nFor more, see the mise Python documentation.

Conclusion\n\nWith mise, you can manage Python 3.11, 3.12, and 3.13 concurrently on WSL2 through straightforward installation and project-specific configuration. The .tool-versions file ensures reproducibility across teams and machines, though you’ll need to consider factors like binary compatibility and shell integration.\n\nKey Takeaways:\n- Install mise with curl https://mise.run | sh, then use mise install python@3.x for versions.\n- Use .tool-versions for per-project pinning; shims handle switching.\n- Suited for WSL2 development, with good VS Code integration.\n\nIf you have questions, comment below. In future articles, we’ll explore mise tasks for Python workflows.

Sponsored by Durable Programming

Need help maintaining or upgrading your Python application? Durable Programming specializes in keeping Python apps secure, performant, and up-to-date.

Hire Durable Programming