[ACCEPTED]-pyYAML - Error - Attribute Error: no attribute "load-pyyaml
If another file named yaml.py is on your 13 sys.path BEFORE the actual PyYaml library, you'll 12 pick up and import that yaml.py file. This 11 includes if you've named your own file yaml.py.
The 10 fact that you're getting yaml.pyc in your 9 directory indicates that this is exactly 8 what you're doing. Your import yaml statement 7 is loading in your own yaml.py file, which 6 causes the interpreter to compile it to 5 yaml.pyc for more efficient running.
Rename 4 the yaml.py file in your directory. Do 3 not name any python file you're working 2 on with the same name as any existing python 1 module you're using, as a general rule.
PyYAML-3.10 has load():
jcomeau@intrepid:/usr/src/clusterFix$ easy_install pyyaml
Searching for pyyaml
Reading http://pypi.python.org/simple/pyyaml/
Reading http://pyyaml.org/wiki/PyYAML
Best match: PyYAML 3.10
Downloading http://pyyaml.org/download/pyyaml/PyYAML-3.10.zip
Processing PyYAML-3.10.zip
Running PyYAML-3.10/setup.py -q bdist_egg --dist-dir /tmp/easy_install-2PnFkZ/PyYAML-3.10/egg-dist-tmp-kCMq7S
build/temp.linux-i686-2.6/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
compilation terminated.
libyaml is not found or a compiler error: forcing --without-libyaml
(if libyaml is installed correctly, you may need to
specify the option --include-dirs or uncomment and
modify the parameter include_dirs in setup.cfg)
zip_safe flag not set; analyzing archive contents...
Adding PyYAML 3.10 to easy-install.pth file
Installed /usr/local/lib/python2.6/dist-packages/PyYAML-3.10-py2.6-linux-i686.egg
Processing dependencies for pyyaml
Finished processing dependencies for pyyaml
jcomeau@intrepid:/usr/src/clusterFix$ python
Python 2.6.7 (r267:88850, Jun 13 2011, 22:03:32)
[GCC 4.6.1 20110608 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> dir(yaml)
['AliasEvent', 'AliasToken', 'AnchorToken', 'BaseDumper', 'BaseLoader', 'BlockEndToken', 'BlockEntryToken', 'BlockMappingStartToken', 'BlockSequenceStartToken', 'CollectionEndEvent', 'CollectionNode', 'CollectionStartEvent', 'DirectiveToken', 'DocumentEndEvent', 'DocumentEndToken', 'DocumentStartEvent', 'DocumentStartToken', 'Dumper', 'Event', 'FlowEntryToken', 'FlowMappingEndToken', 'FlowMappingStartToken', 'FlowSequenceEndToken', 'FlowSequenceStartToken', 'KeyToken', 'Loader', 'MappingEndEvent', 'MappingNode', 'MappingStartEvent', 'Mark', 'MarkedYAMLError', 'Node', 'NodeEvent', 'SafeDumper', 'SafeLoader', 'ScalarEvent', 'ScalarNode', 'ScalarToken', 'SequenceEndEvent', 'SequenceNode', 'SequenceStartEvent', 'StreamEndEvent', 'StreamEndToken', 'StreamStartEvent', 'StreamStartToken', 'TagToken', 'Token', 'ValueToken', 'YAMLError', 'YAMLObject', 'YAMLObjectMetaclass', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', '__with_libyaml__', 'add_constructor', 'add_implicit_resolver', 'add_multi_constructor', 'add_multi_representer', 'add_path_resolver', 'add_representer', 'compose', 'compose_all', 'composer', 'constructor', 'dump', 'dump_all', 'dumper', 'emit', 'emitter', 'error', 'events', 'load', 'load_all', 'loader', 'nodes', 'parse', 'parser', 'reader', 'representer', 'resolver', 'safe_dump', 'safe_dump_all', 'safe_load', 'safe_load_all', 'scan', 'scanner', 'serialize', 'serialize_all', 'serializer', 'tokens']
0
@michaelfilms answer helped me.
I named my 4 testfile yaml.py
and imported PyYAML via import yaml
so it 3 considered itself at source. I renamed my file to test_yaml.py
.
I had to update the import 2 to import yaml
instead of aut-updated import test_yaml
and everything 1 works fine now.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.