Python 3 'json' module is actually corrupted I'm asking this question here and not on Stack Overflow because it appears to be MacOS specific. Many answers over there point to searching for a bad &quot;json.py&quot; module however we can see from the following that no such bad module is being imported.
How do I &quot;fix&quot; the Python 3 installation?
$ python3
Python 3.7.7 (default, Mar 10 2020, 15:43:33) 
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.

&gt;&gt;&gt; import json
&gt;&gt;&gt; d = {'a' : 100, 'b' : 200}
&gt;&gt;&gt; json.dumps(d)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
AttributeError: module 'json' has no attribute 'dumps'

&gt;&gt;&gt; print(json.__file__)
None

Here's where it is located:
$ which python3
/usr/local/bin/python3

I've tried a brew reinstall python3 to no avail.
Well I suppose I will deal with &quot;glib, graphviz and gts&quot; later, but what did the trick for me was to entirely remove the brew installation of Python 3:
brew uninstall --ignore-dependencies python3

And now things are back to normal:
$ python3
Python 3.7.3 (default, Apr 24 2020, 18:51:23) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import json
&gt;&gt;&gt; d = {'a' : 100, 'b' : 200}
&gt;&gt;&gt; json.dumps(d)
'{&quot;a&quot;: 100, &quot;b&quot;: 200}'