I wanted to use python on macOS Big Sur. (I wanted to use a command called CuteR: I made a QR code image with CuteR)
However, when using pip
$ pip install
dyld: Library not loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
Reason: image not found
Abort trap: 6
Will be.
Same with $ python3
.
Python in macOS environment: https://www.python.jp/install/macos/index.html
according to
--Don't try to use the python
that comes with macOS
--Install with Homebrew
--Use python3.9 -m pip xxx
instead of pip3
--Run in a virtual environment such as venv
That's right. Here, I tried up to the above three.
When you do $ brew update
, you will first reach out to dogit --C ...
.
$ brew update
Error: homebrew-core is a shallow clone. To `brew update` first run:
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
First, fetch
and then $ brew update
$ git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
remote: Enumerating objects: 690418, done.
remote: Counting objects: 100% (690359/690359), done.
remote: Compressing objects: 100% (233146/233146), done.
remote: Total 680792 (delta 450632), reused 674814 (delta 444788), pack-reused
Receiving objects: 100% (680792/680792), 271.20 MiB | 14.34 MiB/s, done.
Resolving deltas: 100% (450632/450632), completed with 7510 local objects.
From https://github.com/Homebrew/homebrew-core
baf6aab591..b293a33dd8 master -> origin/master
$ brew update
Install python.
$ brew install python
Warning: [email protected] 3.9.1_3 is already installed, it's just not linked
You can use `brew link [email protected]` to link this version.
It seems that it is included. You just have to link.
$ brew link [email protected]
Linking /usr/local/Cellar/[email protected]/3.9.1_3...
Error: Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
rm '/usr/local/bin/2to3'
To force the link and overwrite all conflicting files:
brew link --overwrite [email protected]
To list all files that would be deleted:
brew link --overwrite --dry-run [email protected]
Hmmm, rm
and brew link
.
$ rm '/usr/local/bin/2to3'
$ brew link --overwrite [email protected]
Linking /usr/local/Cellar/[email protected]/3.9.1_3... 25 symlinks created
I did this
$ pip install
$ python3
Then, the same error as at the beginning. Instead
$ python3.9
Python 3.9.1 (default, Dec 28 2020, 11:25:16)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
I got it! So, try pip
by referring to the following site.
https://www.python.jp/install/macos/pip.html
$ python3.9 -m pip install pillow
Collecting pillow
Downloading Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl (2.2 MB)
|████████████████████████████████| 2.2 MB 3.7 MB/s
Installing collected packages: pillow
Successfully installed pillow-8.0.1
WARNING: You are using pip version 20.3.1; however, version 20.3.3 is available.
You should consider upgrading via the '/usr/local/opt/[email protected]/bin/python3.9 -m pip install --upgrade pip' command.
It is said that you are willing to do so.
$ python3.9 -m pip install --upgrade pip
Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (20.3.1)
Collecting pip
Downloading pip-20.3.3-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 6.2 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.3.1
Uninstalling pip-20.3.1:
Successfully uninstalled pip-20.3.1
Successfully installed pip-20.3.3
According to the above site, once pillow is uninstalled
$ python3.9 -m pip uninstall pillow
Found existing installation: Pillow 8.0.1
Uninstalling Pillow-8.0.1:
Would remove:
/usr/local/lib/python3.9/site-packages/PIL/*
/usr/local/lib/python3.9/site-packages/Pillow-8.0.1.dist-info/*
Proceed (y/n)? y
Successfully uninstalled Pillow-8.0.1
This is fine.
――It was insanely simple and refreshing to say "I don't use the python
included in macOS ".
――I didn't write it here, but "using venv
"was simple and very refreshing.
--Refer to "Creating a QR code image with CuteR" for a usage example.
――Once upon a time, what about pyenv
, so I have a messy memory.
Python in macOS environment: https://www.python.jp/install/macos/index.html Python in macOS environment --pip: https://www.python.jp/install/macos/pip.html
Almost written in ↑. This article is, so to speak, "Tsukurepo".
Python 3.9.1 (Dec 28 2020, 11:25:16) macOS BigSur version 11.1 MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)
Recommended Posts