Pylint error message: "E1101: module" lxml.etree "does not have member" strip_tags ""

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

For some reason, I keep getting the error message: "E1101: Module 'lxml.etree' does not have a member 'strip_tags''.

I am not sure why this is happening.

Here is the relevant part of my code:

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

Any ideas?

Thanks.

+5
source share
1 answer

The reason for this is that pylint by default only trusts C extensions from the standard library and ignores those that are not.

Since lxml is not part of stdlib, you have to whitelist it manually. To do this, go to the directory of your project in the terminal and create an rcfile for pylint:

 $ pylint --generate-rcfile > .pylintrc 

Then open this file and add lxml to the white list as follows:

 extension-pkg-whitelist=lxml 

After that, all E1101 errors regarding lxml should disappear.

More on this answer.

+11
source

Source: https://habr.com/ru/post/1266473/


All Articles