pym3
v1.1.0
Published
Python Version Management, Wrap `pipx` and `poetry` Tools.
Maintainers
Readme
p
Python Version Management, Simplified. Wrap pipx and poetry Tools

p is powerful and feature-packed, yet simple; both in setup and use. There are no tricky settings, options, or crazy dependencies. p is just a helpful ~600 line Bash script that gets the job done.
p let's you quickly switch between Python versions whenever you need to, removing the barrier between Python 2.x.x and 3.x.x.
p was heavily inspired by n, a version manager for Node.js.
p is also great for getting started using Python development versions. Use p latest to get up and running with the latest development version of Python!
Getting Started
After the super painless drag-and-drop installation, you can start using p right away.
Usage
Usage: p [COMMAND] [args]
Commands:
p Output versions installed
p status Output current status
p i <version> Install Python <version> from prebuilt binaries
p <version> Install or Activate Python <version>
p latest Activate the latest Python release
p stable Activate the latest stable Python release
p 3.14 Install the latest Python 3.14 release
p 3.14t Install the latest free-threaded Python 3.14 release
p 3.14.0t Install free-threaded Python 3.14.0
p use <version> [args ...] Execute Python <version> with [args ...]
p bin <version> Output bin path for <version>
p rm <version ...> Remove the given version(s)
p prev Revert to the previously activated version
p default Revert to the system default python version
p ensurepath Add python path to your search path
p unpkg <pkg ...> Remove the given name(s) pip packages and unused dependencies
p shell Add python bin path to a new bash shell
p p Wrap pip command
p px Wrap pipx command
p py Wrap poetry command
p up Update all pipx libs,Wrap pipdate command,update all pip packages
p migrate <ver1> <ver2> Migrate pip package from a Python version to another
p ls Output the versions of Python available
p ls latest Output the latest Python version available
p ls stable Output the latest stable Python version available
Options:
-V, --version Output current version of p
-h, --help Display help information
Environment variables:
P_PREFIX Python versions installation dir ,default: ~/.local
PY_INSTALL_FLAG Global Python configure flags, eg: --enable-optimizations
PY_INSTALL_FLAGS Per-version configure flags, eg: "3.14.0t:--with-lto;3.14.0:--enable-optimizations"
Use "*:flags" to apply flags to every version.
Free-threaded versions (3.14t / 3.14.0t) always add --disable-gil.
GITHUB_MIRROR GitHub download accelerator, default empty (direct). eg: https://ghproxy.net/
A value ending in "/" is used as a URL prefix (ghproxy style), otherwise it
replaces the github.com host (eg: https://githubfast.com).Free-threaded builds (3.14t)
Python 3.14 ships an optional free-threaded (no-GIL) build. Append a t to the
version to build/install it:
p 3.14.0t # free-threaded Python 3.14.0
p 3.14t # latest free-threaded 3.14.x release
p i 3.14t # same, from prebuilt binariesp automatically adds --disable-gil for these builds and installs them under
~/.local/p/versions/python/3.14.0t, so they can coexist with the regular
3.14.0 build.
Per-version custom configure flags can be supplied with PY_INSTALL_FLAGS:
# add to .bashrc
export PY_INSTALL_FLAGS="3.14.0t:--with-lto;3.14.0:--enable-optimizations --with-lto"The PY_INSTALL_FLAG (global) flags are applied first, then the matching
per-version flags, so the per-version ones take precedence.
py3
py3 # the activated python alias
py3 ins pdm # link pdm to `$HOME/.local/bin` dir Installation Python dependencies(Option)
Ubuntu/Debian:
sudo apt-get install -y zstd curl build-essential zlib1g-dev libffi-dev libsqlite3-devCentos/Rocky/Alma/Fedora:
sudo yum install -y zstd curl which diffutils perl gcc gcc-c++ zlib-devel xz-devel sqlite-devel libffi-develmacOS (Apple Silicon / Intel):
xcode-select --install
brew install openssl@3 readline zlib libffi xz zstd pkg-configWhen compiling from source on Linux, p builds OpenSSL 3.0.x into $P_PREFIX/ssl
automatically (Python 3.14 recommends OpenSSL 3.0.x; 1.1.1 is the minimum and is
end-of-life). On macOS it uses Homebrew's openssl@3 instead. On macOS the
Homebrew dependencies above are installed automatically by p when missing
(Homebrew and the Xcode Command Line Tools are required).
Prebuilt binaries (p i) are available for both x86_64-apple-darwin and
aarch64-apple-darwin (Apple Silicon).
Installation
After downloading the Bash script, simply copy it over to your $PATH and p will take care of the rest.
$ curl -o p https://raw.githubusercontent.com/tomasky/pym3/master/bin/p
$ chmod +x p
$ mv p /usr/local/binAlternatively, you can install p via npm:
pnpm install -g pym3So far, p has only been tested in Bash. If you can make p work on another shell, please send in a pull request!
Set python versions installation dir:
# default is `~/.local`
# add this to .bashrc
export P_PREFIX=/usr/localSet python download mirror:
# add this to .bashrc
export PYTHON_MIRROR=https://mirrors.huaweicloud.com/python/Set a GitHub download accelerator (used by p i / p i 3.14t for the prebuilt
binaries). Default is empty, which downloads directly from GitHub:
# add this to .bashrc
# prefix style (mirror URL + original URL), value must end with "/"
export GITHUB_MIRROR=https://ghproxy.net/
# or host style (replaces github.com), value must NOT end with "/"
export GITHUB_MIRROR=https://githubfast.comUpdating
Simply follow the above steps and swap out the old Bash script with the new one!
Contributing
Contributions are always welcome.
Find something interesting in the TODO below, fork our code, create a new branch, and send us a pull request.
There are only two rules: avoid code smells and abide by the syntax-formatting of the existing code.
TODO
- greater abstraction between Python 2.x.x and 3.x.x
- per-directory/project Python version
- also manage PyPy
FAQs
- How does
pdiffer frompyenv?pis designed for the average Python user. You can get up and running with the latest development build of Python with one simple command:p latest. No configuration is necessary;pmanages everything for you.- On the other hand,
pyenvis for the more advanced user who is comfortable configuring their Python environment to all their needs.pprovides the basics in one easy to use aesthetically-pleasing command. - Additionally,
pis easier to use. To switch your Python version, simply runpand you'll be presented with a list of installed Python versions to select from that you can scroll through with your arrow keys and select with the return key. pis great at dealing with any version of Python. If it's not installed, runningp <version>will download the source, configure it for your system, and compile it, all in one simple command.
- How does
pwork?pstores each Python version installed in/usr/local/p/versions/python. When a Python version is activated,pcreates a symbolic link to the Python binary located at/usr/local/p/versions/python/python. Sincepprefixes the $PATH with/usr/local/p/versions/python, this version ofpythonis found first; hence, it is used over the default version of Python installed on your system.
- How do I revert back to my default Python version?
- Simply run
p defaultandpwill remove the symbolic link described above; therefore reverting back to your default Python version.
- Simply run
- Does
pdownload the source each time I activate or install a version?- Nope.
pstores the source for each of the versions installed, allowing for quick activations between already-installed versions.
- Nope.
- How do I get this working on Windows?
- Unfortunately,
pis not supported on Windows at the time. If you know of a workaround, send in a pull request!
- Unfortunately,
License
The below license was included in n and is included below. p's license (also MIT) can be found in the LICENSE file.
(The MIT License)
Copyright (c) 2014 TJ Holowaychuk <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
