简体   繁体   中英

Google colabaratory local runtime 'import package error'

I connected my colab notebook with a local runtime as per in the instructions. But for some reason when I try to import python packages like pandas and numpy, it throws an error,

    TypeErrorTraceback (most recent call last)

/usr/lib/python3.8/codeop.py in __call__(self, source, filename, symbol)
    134 
    135     def __call__(self, source, filename, symbol):
--> 136         codeob = compile(source, filename, symbol, self.flags, 1)
    137         for feature in _features:
    138             if codeob.co_flags & feature.compiler_flag:

TypeError: required field "type_ignores" missing from Module

Help how to fix this. This is the case for any package I try to import.

Note: connected through the local runtime hosted by jupyter notebook.

This error not only shows up at importing but also at all the code below it (probably because the code below it uses the import packages)

Looks like this was reported in CPython https://bugs.python.org/issue35894 and the resolution was that downstream code should add a if sys.version_info >= (3, 8) .

removing the virtual environment and then created the virtual environment again solved it. The following solved that problem:

pip uninstall notebook
pip3 install --ignore-installed --no-cache-dir --upgrade notebook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM