Warning
This plugin is soon to be deprecated in favor of rtx's built-in core python functionality.
Python plugin for rtx version manager
rtx plugin add python
Enable to fix macOS 11 issues
You can use environment variable RTX_PYTHON_PATCH_URL to install with --patch like that:
export RTX_PYTHON_PATCH_URL="https://github.com/python/cpython/commit/8ea6353.patch?full_index=1"
rtx install python 3.6.12
or use environment variable RTX_PYTHON_PATCHES_DIRECTORY.
Check rtx readme for instructions on how to install & manage versions of Python. Please make sure you have the required system dependencies installed before trying to install Python.
Under the hood, rtx-python uses python-build to build and install Python, check its README for more information about build options and the common build problems wiki page for any issues encountered during installation of python versions.
A common request for Python is being able to use the python2 and python3 commands without needing to switch version.
This can be achieved by setting multiple versions of Python, for example with
rtx global python 3.6.2 2.7.13
Executables in the first version will take priority over the executables in the next one. Note that you can use an arbitrary number over versions, if needed.
With the above example, python will therefore use the python executable found in version 3.6.2.
However, as the python2 does not exist in Python 3.6.2, python2 will use the python2 executable found in version 2.7.13.
python -V
Python 3.6.2
python3 -V
Python 3.6.2
python2 -V
Python 2.7.13
If you use pip to install a module like ipython that has binaries. You will need to run rtx reshim python for the binary to be in your path.
rtx-python can automatically install a default set of Python packages with pip right after installing a Python version. To enable this feature, provide a $HOME/.default-python-packages file that lists one package per line, for example:
ansible
pipenv
You can specify a non-default location of this file by setting a RTX_PYTHON_DEFAULT_PACKAGES_FILE variable.
Automatically create and activate a virtualenv when entering a directory with the
virtualenv option. This requires using .rtx.toml since .tool-versions could
not support this syntax:
[tools]
python = { version='3.11', virtualenv='.venv' }This functionality has been removed from this plugin and instead put into rtx-pipenv and rtx-poetry.