RonenNess / html_validator

Offline HTML validator for Python, based on the standard v.Nu
MIT License
6 stars 5 forks source link

validate not defined. #6

Closed Beyarz closed 6 years ago

Beyarz commented 6 years ago

When running the script:

try:
import os
from html_validator import validate
except(ImportError):
print("Could not import lib.")
errors = validate("index.html")
for err in errors:
print("Type: %s, File: %s, Line: %d, Description: %s" % (err.type, err.file, err.line, err.description))

I get this error:

Traceback (most recent call last):
File "validate.py", line 13, in <module>
errors = validate("index.html")
NameError: name 'validate' is not defined

Can't figure out why.

RonenNess commented 6 years ago

Your error says line 13 but in your code its line 6. This tells me its not the same code. Its probably something in your code / you are not really running what you think you're running.

Please open a Python shell and run the following commands:

>>> from html_validator import validate
>>> errors = validate("index.html")

Without anything else - if that doesn't work - please reopen the issue. Thanks! :)

Beyarz commented 6 years ago

The code was same, I just removed a couple of lines that were sensitive before posting it in here. I managed to resolve the issue anyways. I executed the script with python 3.7 instead of 2.7. That was the issue, took me some time to realize that.

RonenNess commented 6 years ago

Ahh I see, maybe I should add some warning if someone tries to import in Python 3... You are not the first trying to use it with 3 instead of 2. Glad to hear you figured it out! :)

Beyarz commented 6 years ago

A warning would definitely be useful for cases like these.