Python Versions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 25: Line 25:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
brew install python@3.12
brew install python@3.12
</syntaxhighlight>
If multiple versions are installed this way, only one is symlinked in <code>/usr/local/bin/python</code> and <code>/usr/local/bin/python3</code> <font color=darkkhaki>(which one?, looks like the newest one)</font>
To use a specific version other than the one symlinked, update the <code>PATH</code>:
<syntaxhighlight lang='bash'>
export PATH="/usr/local/opt/python@3.7/bin:${PATH}"
</syntaxhighlight>
</syntaxhighlight>



Revision as of 22:04, 2 November 2023

Internal

Overview

This page document how to deal with multiple Python versions on the same system. pyenv is a tool that deals with that.

Python Version Management with Brew

brew install different Python major and minor versions in Cellar using the following naming scheme:

 Cellar
  ├─ ...
  ├─ python@3.8
  ├─ python@3.9
  ├─ python@3.10
  ├─ python@3.11
  ├─ python@3.12
  ├─ ...

The default Cellar location is /usr/local/Cellar but may differ depending on the brew instance. See:

brew Concepts | Cellar

Install a Specific Version

brew install python@3.12

If multiple versions are installed this way, only one is symlinked in /usr/local/bin/python and /usr/local/bin/python3 (which one?, looks like the newest one)

To use a specific version other than the one symlinked, update the PATH:

export PATH="/usr/local/opt/python@3.7/bin:${PATH}"

Update a Specific Version to a Newer Patch Level

brew upgrade python@3.12

pip relationship to Python Version

pip installs the packages in a directory