Python Versions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 34: Line 34:
=<tt>pip</tt> relationship to Python Version=
=<tt>pip</tt> relationship to Python Version=


<code>pip</code> installs the packages in a directory  
<code>pip</code> installs the packages in a directory
 
 
 
==Multiple Python Versions==
 
 
Installs in <code>/usr/local/Cellar/python@3.7</code> while preserving the current <code>/usr/local/Cellar/python@3.9</code>.
 
This version is not symlinked in <code>/usr/local/bin</code>. To use it:
<syntaxhighlight lang='bash'>
export PATH="/usr/local/opt/python@3.7/bin:${PATH}"
</syntaxhighlight>

Revision as of 22:00, 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

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