如何解决错误:模块“平台”没有属性“ linux_distribution”
在执行程序时出现以下错误。
这是一个解析上传文档的程序。
当用户尝试上传文档时,错误就会出现
Error: module 'platform' has no attribute 'linux_distribution'
Path: tmp/resume_2020-08-28_10-09-05/Document.pdf
Traceback (most recent call last):
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/wand/api.py",line 143,in <module>
libraries = load_library()
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/wand/api.py",line 132,in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []
During handling of the above exception,another exception occurred:
Traceback (most recent call last):
File "/home/adiagarwal/projects/BackEnd/admin_api.py",line 198,in post
im = page.to_image()
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pdfplumber/page.py",line 255,in to_image
from .display import PageImage,DEFAULT_RESOLUTION
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pdfplumber/display.py",line 3,in <module>
import wand.image
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/wand/image.py",line 18,in <module>
from . import assertions
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/wand/assertions.py",line 125,in <module>
from .color import Color # noqa: E402
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/wand/color.py",line 10,in <module>
from .api import library
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/wand/api.py",line 161,in <module>
distname,_,__ = platform.linux_distribution()
AttributeError: module 'platform' has no attribute 'linux_distribution'
Error: 'resume_link'
Traceback (most recent call last):
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/indexes/base.py",line 4736,in get_value
return libindex.get_value_box(s,key)
File "pandas/_libs/index.pyx",line 51,in pandas._libs.index.get_value_box
File "pandas/_libs/index.pyx",line 47,in pandas._libs.index.get_value_at
File "pandas/_libs/util.pxd",line 98,in pandas._libs.util.get_value_at
File "pandas/_libs/util.pxd",line 83,in pandas._libs.util.validate_indexer
TypeError: 'str' object cannot be interpreted as an integer
During handling of the above exception,line 794,in write_to_db
additional_params.update({k: query_obj.n4j_escape(row[k]) for k in ['Name','DOB',"Email","resume_link","Total Work Experience","City","Age"]})
File "/home/adiagarwal/projects/BackEnd/admin_api.py",in <dictcomp>
additional_params.update({k: query_obj.n4j_escape(row[k]) for k in ['Name',"Age"]})
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/series.py",line 1071,in __getitem__
result = self.index.get_value(self,key)
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/indexes/base.py",line 4744,in get_value
raise e1
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/indexes/base.py",line 4730,in get_value
return self._engine.get_value(s,k,tz=getattr(series.dtype,"tz",None))
File "pandas/_libs/index.pyx",line 80,in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx",line 88,line 131,in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi",line 1607,in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi",line 1614,in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'resume_link'
Error: "['resume_link'] not found in axis"
Traceback (most recent call last):
File "/home/adiagarwal/projects/BackEnd/admin_api.py",line 753,in evaluate
df = df.drop(["CV Source","Date of Interview 1","Department","Gap Duration - B/w Jobs","Gap Duration - Edu to Job","HR SPOC","Name of Interviewer 1","Role","Sr no","Sub Department","resume_link"],axis=1)
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/frame.py",line 4110,in drop
return super().drop(
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/generic.py",line 3914,in drop
obj = obj._drop_axis(labels,axis,level=level,errors=errors)
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/generic.py",line 3946,in _drop_axis
new_axis = axis.drop(labels,errors=errors)
File "/home/adiagarwal/Python-3.8.0/resume_parser_env/lib/python3.8/site-packages/pandas/core/indexes/base.py",line 5340,in drop
raise KeyError("{} not found in axis".format(labels[mask]))
KeyError: "['resume_link'] not found in axis"
--- 6.292607069015503 seconds ---
我正在Ubuntu 18.04- WSL2上运行它。使用龙卷风Neo4j
我尝试过:
- Ansible error: AttributeError: module 'platform' has no attribute 'dist'
- Python doesn't find MagickWand Libraries (despite correct location?)
- How to fix “module 'platform' has no attribute 'linux_distribution'” when installing new packages with Python3.8?
解决方法
Python 3.8从平台模块中删除了“ linux_distribution()”功能。替换为“发行版”模块中的等效项(发行版不是Python内置的,必须通过pip安装)。
如果您无法更改源代码,则可以尝试将Python降级为Python 3.7
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。