当前位置:   article > 正文

运行Python文件报错:AttributeError: partially initialized module ‘keyword‘ has no attribute ‘kwlist‘_index = faiss.indexflatl2(dim) attributeerror: par

index = faiss.indexflatl2(dim) attributeerror: partially initialized module

问题:

在运行python文件时报错,提示AttributeError: partially initialized module 'keyword' has no attribute 'kwlist' (most likely due to a circular import)

 原因:

这是因为文件命与包(import 导入的 keyword包)名重复了,把文件命重新修改过就行了

解决办法:

1. 找到文件右击---->选择Refator---->Rename

 2. 在1处从新修改文件名字---->refactor

 3. 修改好之后可能会出现如下情况,把import keyword_demo改为 import keyword即可

 4. 之后运行就不会报错啦。

提示:在创建包的时候,报名不要用关键字,在定义变量的时候变量也不要用关键字

关键字如下:

'False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except','finally', 'for', 'from', 'global', 'if','import', 'in', 'is','lambda', 'nonlocal', 'not', 'or', 'pass','raise', 'return', 'try', 'while', 'with', 'yield'

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/884296
推荐阅读
相关标签
  

闽ICP备14008679号