Note: I have read Python: TypeError: required field "type_ignores" missing from Module in Jupyter notebook, which contains a similar problem. However, I am still stuck.
Problem: I have just updated from Python 3.7.5 to Python 3.8.5. However, when I run code in Jupyter Notebook, the following error message is displayed:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/codeop.py in __call__(self, source, filename, symbol)
139
140 def __call__(self, source, filename, symbol):
--> 141 codeob = compile(source, filename, symbol, self.flags, 1)
142 for feature in _features:
143 if codeob.co_flags & feature.compiler_flag:
TypeError: required field "type_ignores" missing from Module
I get this message when I run code like
i = 1
or code like
import numpy as np
or code like
from platform import python_version
print(python_version())
I have read Python: TypeError: required field "type_ignores" missing from Module in Jupyter notebook, which contains a similar problem. However, the poster in that question had an outdated ipython version. I did a
pip freeze
and found that I had the newest version (7.2.0), which means that the solution to that problem does not apply to this problem.
Below is some extra information if you need:
What I tried: I first tried to revert from Python 3.8 to Python 3.7. This is because the error message mentioned that the error was coming from /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/codeop.py I tried to do this by downloading pyenv and python 3.7 again (I had python 3.7 before but it had disappeared) and setting the python version to 3.7.5 by configuring the .zshenv file. However, that caused jupyter notebook and even programs like emacs to stop working with messages like
command not found: jupyter
and
command not found: emacs
I finally did it by downloading the python 3.7.5 pkg file from the python website:
python --version
output:
Python 3.7.5
However, when I launch Jupyter Notebook, I still get the same error as before ("TypeError: required field "type_ignores" missing from Module"). I am afraid that installing Python 3.8 did some permanent damage.
This is my .zshenv file configuration:
export SACAUX=SACHOME/aux
export SACHOME=/usr/local/sac
export PATH=${PATH}:${SACHOME}/bin
export PATH=SACHOME/bin
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:SACHOME/bin
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:SACHOME/bin:HOME/.pyenv/bin
export PATH=~/.pyenv/versions/3.7.5/bin:${PATH}
export PYTHONPATH=/usr/local/lib/python3.7/site-packages
FYI, (If this is useful), All of the packages I need (tensorflow, numpy, scipy) are in /usr/local/lib/python3.7/site-packages, a python 3.7 folder, so I had to explicitly set PYTHONPATH to /usr/local/lib/python3.7/site-packages so that Python can find the packages to import.
What are some fixes to solve this "TypeError: required field "type_ignores" missing from Module"?