我需要转换所有python依赖文件,例如。 Requirements.txt和Pipfile,Pipfile.lock锁定为易于解析的json格式。
我选择使用https://github.com/pyupio/dparse。因为它是唯一的存储库,所以我可以找到它。
但是,出现此错误。
print(df.json())
File "C:\Python36\lib\site-packages\dparse\dependencies.py", line 183, in json
return json.dumps(self.serialize(), indent=2)
File "C:\Python36\lib\json\__init__.py", line 238, in dumps
**kw).encode(obj)
File "C:\Python36\lib\json\encoder.py", line 201, in encode
chunks = list(chunks)
File "C:\Python36\lib\json\encoder.py", line 430, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\Python36\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
File "C:\Python36\lib\json\encoder.py", line 325, in _iterencode_list
yield from chunks
File "C:\Python36\lib\json\encoder.py", line 404, in _iterencode_dict
yield from chunks
File "C:\Python36\lib\json\encoder.py", line 437, in _iterencode
o = _default(o)
File "C:\Python36\lib\json\encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'SpecifierSet' is not JSON serializable
我仅尝试运行作者本人给出的示例。我使用'pip install dparse'安装了dparse
有没有办法解决这个问题?