Master Python Version Management with pythonbrew: Install, Switch, and Isolate Easily
This guide explains how to install pythonbrew, configure it for user or system-wide use, and leverage its commands to install, switch, and manage multiple Python versions and isolated environments on Linux.
Welcome to pythonbrew documentation
Manage Python installations in your $HOME directory.
Introduction
pythonbrew is inspired by perlbrew and rvm and automates building and installing Python versions in the user's $HOME directory.
Another derivative: pythonz.
Installation
Use the following command to download and install pythonbrew: $ curl -kL http://xrl.us/pythonbrewinstall | bash pythonbrew will be installed to ~/.pythonbrew.
Add the following line to your ~/.bashrc:
[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrcOn macOS, where .bashrc may not exist, create a .bash_profile and add the same line, then source it.
Set PYTHONBREW_ROOT to install pythonbrew to a custom directory:
$ export PYTHONBREW_ROOT=/path/to/pythonbrew
$ curl -kLO http://xrl.us/pythonbrewinstall
$ chmod +x pythonbrewinstall
$ ./pythonbrewinstallSystem-wide (multi‑user) installation
Running the install script as root installs pythonbrew to /usr/local/pythonbrew and configures it for all users.
Non‑root users can then use pythonbrew without sudo, e.g.:
$ sudopybrew install -n -v -j2 2.7.2Usage
General syntax: pythonbrew command [options] Install a specific Python version:
pythonbrew install 2.7.2
pythonbrew install --verbose 2.7.2
pythonbrew install --test 2.7.2
pythonbrew install --test --force 2.7.2
pythonbrew install --configure="CC=gcc_4.1" 2.7.2
pythonbrew install --no-setuptools 2.7.2
pythonbrew install http://www.python.org/ftp/python/2.7/Python-2.7.2.tgz
pythonbrew install /path/to/Python-2.7.2.tgz
pythonbrew install /path/to/Python-2.7.2
pythonbrew install 2.7.2 3.2Make a version the default for every login:
pythonbrew switch 2.7.2
pythonbrew switch 3.2Use a version temporarily in the current shell: pythonbrew use 2.7.2 Run a Python file with any installed version(s):
pythonbrew py test.py
pythonbrew py -v test.py
pythonbrew py -p 2.7.2 -p 3.2 test.pyList installed versions: pythonbrew list List installable versions: pythonbrew list -k Uninstall a version:
pythonbrew uninstall 2.7.2
pythonbrew uninstall 2.7.2 3.2Clean up old source directories and archives: pythonbrew cleanup Update pythonbrew:
pythonbrew update
pythonbrew update --master
pythonbrew update --developDisable pythonbrew (return to the original environment): pythonbrew off Create or remove symbolic links to a Python version in your $PATH:
pythonbrew symlink
pythonbrew symlink -p 2.7.2
pythonbrew symlink pip
pythonbrew symlink -r
pythonbrew symlink -v fooRun buildout with the current or a specific Python version:
pythonbrew buildout
pythonbrew buildout -p 2.6.6Create isolated Python environments using virtualenv:
pythonbrew venv init
pythonbrew venv create proj
pythonbrew venv list
pythonbrew venv use proj
pythonbrew venv delete proj
pythonbrew venv rename proj proj2Show pythonbrew version:
pythonbrew versionCommands
install <version> – Build and install a specific Python version with setuptools and pip.
switch <version> – Permanently set a specific Python version as the default.
use <version> – Use a specific version in the current shell.
py <python file> – Run a Python file with all or a specified version.
list – List all installed Python versions.
list -k – List all installable Python versions.
uninstall <version> – Remove a specific Python version.
cleanup – Remove outdated source directories and archives.
update – Upgrade pythonbrew to the latest version.
off – Disable pythonbrew and revert to the original environment.
symlink – Create or remove symbolic links to a Python version in $PATH.
buildout – Run buildout with the current or a specific Python version.
venv – Manage isolated Python environments via virtualenv.
version – Show the pythonbrew version.
For more details, run:
$ pythonbrew help <command>Related documents and links
Python virtual environments and multi‑version development tools – Virtualenv and pythonbrew.
pythonbrew – Quickly switch between different Python versions.
License
MIT Open Source License
Copyright (c) <2010-2012> <utahta>
Anyone may freely use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software and its documentation, provided the following conditions are met:
The copyright and permission notice must be included in all copies or substantial portions of the software.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
