I want to use Python 3 on my Mac High Sierra system. I installed with brew using the following ...
localhost:tmp davea$ brew reinstall python3
==> Reinstalling python
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.6_1.high_sierra.bottle.tar.gz
Already downloaded: /Users/davea/Library/Caches/Homebrew/downloads/3d94ccb6613548e55aed20c7ee59f0e0b7fb045a5d9c8885aa3504ea31f8ab0e--python-3.7.6_1.high_sierra.bottle.tar.gz
==> Pouring python-3.7.6_1.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/python/3.7.6_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/pyt
==> /usr/local/Cellar/python/3.7.6_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/pyt
==> /usr/local/Cellar/python/3.7.6_1/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/pyt
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
/usr/local/Cellar/python/3.7.6_1: 3,977 files, 60.8MB
However, when I try and run a simple command, I'm getting a "ModuleNotFoundError: No module named 'encodings'" error. I'm just trying to parse some JSON. What else do I need to do to get Python installed properly?
localhost:tmp davea$ echo $json
{"id": "abc", "name": "dave"}
localhost:tmp davea$ echo $json | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["id"])'
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fff9f066380 (most recent call first):
Abort trap: 6
localhost:tmp davea$ echo $json | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj["id"])'
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fff9f066380 (most recent call first):
Abort trap: 6: