From fe114143b8edf619b2617adb73192fffe275354f Mon Sep 17 00:00:00 2001 From: MichaelCurrin Date: Fri, 9 Aug 2024 14:32:52 +0000 Subject: [PATCH] deploy: c584b78f5750269333adf273f65753f1f99d58ad --- .../python/install/install-and-upgrade.html | 67 +++++++++++-------- .../python/install/install-and-upgrade.md | 44 +++++++----- feed.xml | 2 +- 3 files changed, 67 insertions(+), 46 deletions(-) diff --git a/cheatsheets/python/install/install-and-upgrade.html b/cheatsheets/python/install/install-and-upgrade.html index 8cb102135..686eaa61e 100644 --- a/cheatsheets/python/install/install-and-upgrade.html +++ b/cheatsheets/python/install/install-and-upgrade.html @@ -180,21 +180,21 @@

Linux

Using apt-get.

-

Latest

+

Latest for your OS

$ sudo apt-get install -y python3
 

Target

-
$ sudo apt-get install -y python3.7
+
$ sudo apt-get install -y python3.12
 

Non-standard

-

If the APT repositories don’t support the old or new version you’re after.

+

If the APT repositories don’t support an old or new version you’re after, add a custom repository as below.

-

Using deadsnakes PPA for Ubuntu.

+

Using deadsnakes PPA for Ubuntu:

$ sudo add-apt-repository ppa:deadsnakes/ppa
 $ sudo apt-get install -y python3.7
@@ -208,17 +208,30 @@ 

macOS

Install

-

Using the python@3.9 formula.

+

Install the latest:

+ +
$ brew install python
+
+ +

Install target version e.g. python@3.9 formula.

$ brew install python@3.9
 
-

Or for latest:

+

See Python Homebrew docs.

-
$ brew install python
+

Upgrade

+ +

Upgrade existing:

+ +
$ brew upgrade python
 
-

Upgrading

+

Or install a target version and set it as the default using Change default version.

+ +

Or install a target version and uninstall the old versions, breaking any apps and virtual environments that use them.

+ +

My experience

I had 3 versions of PY3 installed.

@@ -268,10 +281,8 @@

Upgrading

Try this to sort out the linking:

-
$ brew unlink python && brew link python
-
- -
Unlinking /usr/local/Cellar/python@3.8/3.8.6... 2 symlinks removed
+
$ brew unlink python && brew link python
+Unlinking /usr/local/Cellar/python@3.8/3.8.6... 2 symlinks removed
 Linking /usr/local/Cellar/python@3.8/3.8.6...
 Error: Could not symlink bin/pip3
 Target /usr/local/bin/pip3
@@ -283,24 +294,24 @@ 

Upgrading

To list all files that would be deleted: brew link --overwrite --dry-run python@3.8 -
+

Or

-
$ brew unlink python
-$ brew link python@3.9
-Warning: python@3.9 is keg-only and must be linked with --force
+
$ brew unlink python
+$ brew link python@3.9
+Warning: python@3.9 is keg-only and must be linked with --force
 
-If you need to have this software first in your PATH instead consider running:
-  echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc
-
+If you need to have this software first in your PATH instead consider running: + echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc +
-
$ brew link python@3.9 --force
-Linking /usr/local/Cellar/python@3.9/3.9.0... 21 symlinks created
+
$ brew link python@3.9 --force
+Linking /usr/local/Cellar/python@3.9/3.9.0... 21 symlinks created
 
-If you need to have this software first in your PATH instead consider running:
-  echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc
-
+If you need to have this software first in your PATH instead consider running: + echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc +
$ python3 -V
 Python 3.7.3
 
@@ -316,12 +327,12 @@

Upgrading

Also I can’t just delete the old one as it is used by other Brew packages.

-
$ brew uninstall python@3.8
-Error: Refusing to uninstall /usr/local/Cellar/python@3.8/3.8.6
+
$ brew uninstall python@3.8
+Error: Refusing to uninstall /usr/local/Cellar/python@3.8/3.8.6
 because it is required by ipython, libxml2 and libxmlsec1, which are currently installed.
 You can override this and force removal with:
-  brew uninstall --ignore-dependencies python@3.8
-
+ brew uninstall --ignore-dependencies python@3.8 +

Doing an install of Python 3.9 made it the default without having to update my PATH.

diff --git a/cheatsheets/python/install/install-and-upgrade.md b/cheatsheets/python/install/install-and-upgrade.md index 667bc9ce2..7d84bdf8a 100644 --- a/cheatsheets/python/install/install-and-upgrade.md +++ b/cheatsheets/python/install/install-and-upgrade.md @@ -10,7 +10,7 @@ See more info in these gists: Using `apt-get`. -### Latest +### Latest for your OS ```sh $ sudo apt-get install -y python3 @@ -19,14 +19,14 @@ $ sudo apt-get install -y python3 ### Target ```sh -$ sudo apt-get install -y python3.7 +$ sudo apt-get install -y python3.12 ``` ### Non-standard -If the APT repositories don't support the old or new version you're after. +If the APT repositories don't support an old or new version you're after, add a custom repository as below. -Using [deadsnakes PPA](https://launchpad.net/%7Edeadsnakes/+archive/ubuntu/ppa) for Ubuntu. +Using [deadsnakes PPA](https://launchpad.net/%7Edeadsnakes/+archive/ubuntu/ppa) for Ubuntu: ```sh $ sudo add-apt-repository ppa:deadsnakes/ppa @@ -44,20 +44,35 @@ Note that upgrading Python with Homebrew causes all my virtual envs to break. Us ### Install -Using the [python@3.9](https://formulae.brew.sh/formula/python@3.9) formula. +Install the latest: + +```sh +$ brew install python +``` + +Install target version e.g. [python@3.9](https://formulae.brew.sh/formula/python@3.9) formula. ```sh $ brew install python@3.9 ``` -Or for latest: +See [Python Homebrew docs](https://docs.brew.sh/Homebrew-and-Python). + +### Upgrade + +Upgrade existing: ```sh -$ brew install python +$ brew upgrade python ``` +Or install a target version and set it as the default using [Change default version][]. + +Or install a target version and uninstall the old versions, breaking any apps and virtual environments that use them. -### Upgrading +[Change default version]: {% link cheatsheets/python/install/change-default-version.md %} + +#### My experience I had 3 versions of PY3 installed. @@ -79,7 +94,6 @@ python@3.8: stable 3.8.6 (bottled) Python 3.9 got installed because `sphinx-doc` has it as a dependency, but it did not replace the existing one. See notes from the output. - ``` ==> python@3.9 Python has been installed as @@ -112,11 +126,8 @@ For pkg-config to find python@3.9 you may need to set: Try this to sort out the linking: -```sh +```console $ brew unlink python && brew link python -``` - -``` Unlinking /usr/local/Cellar/python@3.8/3.8.6... 2 symlinks removed Linking /usr/local/Cellar/python@3.8/3.8.6... Error: Could not symlink bin/pip3 @@ -133,7 +144,7 @@ To list all files that would be deleted: Or -```sh +```console $ brew unlink python $ brew link python@3.9 Warning: python@3.9 is keg-only and must be linked with --force @@ -142,8 +153,7 @@ If you need to have this software first in your PATH instead consider running: echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc ``` - -```sh +```console $ brew link python@3.9 --force Linking /usr/local/Cellar/python@3.9/3.9.0... 21 symlinks created @@ -167,7 +177,7 @@ Then you can add this to `PATH` - `/usr/local/opt/python@3`. Also I can't just delete the old one as it is used by other Brew packages. -```sh +```console $ brew uninstall python@3.8 Error: Refusing to uninstall /usr/local/Cellar/python@3.8/3.8.6 because it is required by ipython, libxml2 and libxmlsec1, which are currently installed. diff --git a/feed.xml b/feed.xml index e85685e8a..51e633fa6 100644 --- a/feed.xml +++ b/feed.xml @@ -1 +1 @@ -Jekyll2024-08-09T14:26:30+00:00https://michaelcurrin.github.io/dev-cheatsheets/feed.xmlDev CheatsheetsA collection of code snippets and CLI guides for quick and easy reference while codingMichael Currin \ No newline at end of file +Jekyll2024-08-09T14:32:13+00:00https://michaelcurrin.github.io/dev-cheatsheets/feed.xmlDev CheatsheetsA collection of code snippets and CLI guides for quick and easy reference while codingMichael Currin \ No newline at end of file