RonenNess / html_validator

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

ImportError #1

Closed PlutoHimself closed 6 years ago

PlutoHimself commented 6 years ago

import html_validator Traceback (most recent call last): File "", line 1, in import html_validator File "C:\Anaconda3\lib\site-packages\html_validator__init__.py", line 10, in from html_validator import validate, MissingValidatorOrJava, MissingHtmlFile, ValidationError ImportError: cannot import name 'validate'

I tried to import into a script and this was the error thrown. This is technically from the Spyder console, the import command I called in my file was the same traceback just slightly longer. Thoughts?

PlutoHimself commented 6 years ago

If I comment out the "from html_validator"... line in init.py, it imports, but obviously that function/those classes are unavailable.

RonenNess commented 6 years ago

You're using Python 3.5 right (the Anaconda3 part)? I wrote this for Python 2.7 I don't know if it works on Python 3..

You could try changing the import line to

from . import html_validator

And then use it like this

html_validator.html_validator.validate()

If that doesn't work either you can just copy the html_validator.py and vnu.jar directly into your working folder, that's all the files you need..

Let me know if it helped :)

PlutoHimself commented 6 years ago

Yes, I am.

It REALLY hated having it as an external module, even with the .py/.jar in the working folder. But it was perfectly happy to execute once the classes/function were inside my file (after a couple of Python 3 adjustments for bytes objects). I also had to raise the thread stack.

All that being said, it worked perfectly, so thank you for implementing this directly! I'm attempting to grade student assignments, and it is far, far quicker to be able to do this than upload each file one-by-one. If only the CSS validator worked better!

RonenNess commented 6 years ago

That's a cool use-case for the utility :) Glad to hear you managed to work things out, I'm closing this issue now, if you have any more issues feel free to open new tickets.

Cheers!