Error: module 'platform' has no attribute 'linux_distribution'

Error: module 'platform' has no attribute '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, another exception occurred:

Traceback (most recent call last):
  File "/home/adiagarwal/projects/BackEnd/admin_api.py", 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", line 794, in <dictcomp>
    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/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, in pandas._libs.index.IndexEngine.get_value
  File "pandas/_libs/index.pyx", 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,龙卷风

我试过:

Python 3.8 从平台模块中删除了“linux_distribution()”函数。它被“distro”模块中的等效项替换(distro 不是 built-in 到 Python,必须通过 pip 安装)。

如果您无法更改源代码,可以尝试将 Python 降级到 Python 3.7