[英]Google colabaratory local runtime 'import package error'
I connected my colab notebook with a local runtime as per in the instructions.我按照说明将我的 colab 笔记本与本地运行时连接。 But for some reason when I try to import python packages like pandas and numpy, it throws an error,但是由于某种原因,当我尝试导入 python 包(如 pandas 和 numpy)时,会引发错误,
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.我尝试导入的任何 package 都是这种情况。
Note: connected through the local runtime hosted by jupyter notebook.注意:通过 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)
.看起来这是在 CPython https://bugs.python.org/issue35894中报告的,解决方案是下游代码应添加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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.