Pylint Error Message: "E1101: Module 'lxml.etree' has no 'strip_tags' member'"
Asked Answered
C

1

21

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.

Chamberlain answered 7/4, 2017 at 14:20 Comment(9)
Can you tell us what page you're processing?Greasepaint
@BillBell It's a local html file that I created from a random program that uses html natively to display formatted text. I copied and pasted from the program and saved it as html. The markup is super messy and overdone, so I am writing this script in python to clean it up.Chamberlain
To clarify: The script is working. I did make some mistakes in the execution of the function, but I fixed them and they are separate from this error message. Even with the code working, the error message persists. Really strange.Chamberlain
It 'appears' that etree has been re-defined. Possible?Greasepaint
@BillBell I don't think so because the documentation remains the same and the script is functioning. It actually does its job. So, if it was redefined or removed, it wouldn't work at all, right? I saw some other posts about Pylint E1101 Error message being raised falsely. Didn't see any solutions, though. Strange.Chamberlain
Just guessing. As long as etree isn't used subsequently in the script, it would only raise an exception in this statement.Greasepaint
I have to come clean. I missed the mention of PyLint in your question!Greasepaint
@BillBell Lol, I probably wasn't clear enough. Thanks, though. I have a feeling this is not a very simple thing to figure out and might not be worth the trouble as long as the script is working.Chamberlain
Oh, you were clear enough. I must be developing a name on here for this.Greasepaint
A
33

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, edit .pylintrc to add lxml to the whitelist (see pylint documentation):

extension-pkg-allow-list=lxml

After that, all E1101 errors regarding lxml should vanish.

More details in this answer.

Anemic answered 1/6, 2017 at 9:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.