Python 模块“yaml”没有属性“FullLoader”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/55551191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
module 'yaml' has no attribute 'FullLoader'
提问by B Srinivas MVGR ECE
I am seeing the following error:
我看到以下错误:
Traceback (most recent call last):
File "generateLDA.py", line 14, in <module>
config = yaml.load(fp, Loader = yaml.FullLoader)
AttributeError: module 'yaml' has no attribute 'FullLoader'
回答by larsks
The FullLoader
class is only available in PyYAML 5.1 and later. Version 5.1 was released on March 13, 2019and has probably not filtered down to many distributions yet.
该FullLoader
班仅在PyYAML 5.1及更高版本。5.1 版于2019 年 3 月 13 日发布,可能尚未筛选到许多发行版。
You can check the version of PyYAML by inspecting yaml.__version__
:
您可以通过检查来检查 PyYAML 的版本yaml.__version__
:
Python 2.7.15 (default, Oct 15 2018, 15:24:06)
[GCC 8.1.1 20180712 (Red Hat 8.1.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.13'
If you are managing packages with pip
, you can upgrade to the current release by running:
如果您使用 管理软件包pip
,则可以通过运行以下命令升级到当前版本:
pip install -U PyYAML