Pylint Error Message: “E1101: Module 'lxml.etree' has no 'strip_tags' member'”

天涯浪子 提交于 2019-12-04 11:12:05

问题


I am experimenting with lxml and python for the first time for a personal project, and I am attempting to strip tags from a bit of source code using etree.strip_tags().

For some reason, I keep getting the error message: "E1101: Module 'lxml.etree' has no 'strip_tags' member'".

I'm not sure why this is happening.

Here's the relevant portion of my code:

from lxml import etree

...

DOC = etree.strip_tags(DOC_URL, 'html')
print DOC

Any ideas?

Thanks.


回答1:


The reason for this is that pylint by default only trusts C extensions from the standard library and will ignore those that aren't.

As lxml isn't part of stdlib, you have to whitelist it manually. To do this, navigate to the directory of your project in a terminal, and generate an rcfile for pylint:

$ pylint --generate-rcfile > .pylintrc

Then, open that file and add lxml to the whitelist like so:

extension-pkg-whitelist=lxml

After that, all E1101 errors regarding lxml should vanish.

More details in this answer.



来源:https://stackoverflow.com/questions/43280486/pylint-error-message-e1101-module-lxml-etree-has-no-strip-tags-member

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!