3

Please excuse: This is my first step into python. So consider this a beginners question:

https://github.com/paradonym/...

This forked script checks a twitter page for words and sends a mail (probably using .qmail) to the owner.
If I execute this python:
"[$USER@$HOST uberspace-downtime-notify]$ python fetch.py
Traceback (most recent call last):
File "fetch.py", line 11, in <module>
import html
ImportError: No module named html
"
Similar errors are fixed in this github commit https://github.com/datalib/... - but that's a more complex script and I don't quite get where the imported module is needed (on a code basis - on the logical basis all is clear)

Any idea for a guy with his first steps into python and back into programming languages since some years=

Comments
  • 1
    Things to check: what OS are you running? What python version?
  • 1
    [$USER@$HOST ~]$ cat /etc/*release
    CentOS release 6.9 (Final)
    [$USER@$HOST ~]$ python --version
    Python 2.6.6
  • 1
    Okay, so in python 3 they changed the naming of the HTML module a lot. So to get it to work you'll need to change a line of code with two lines.

    Change 'import html'
    With:
    from HTMLParser import HTMLParser
    html = HTMLParser()

    Hope that helps!
  • 1
    that seems to work. Thanks...
    Could it be that this is something developed for python 3 and incompatible for python 2?
    I had to change definitions beforehand from "def add_stored_hash(hash: str):" to "def add_stored_hash(hash):" because of syntax errors. Our other python learners said something like "python guesses which data type is needed and is mostly right"

    Did I just made https://github.com/wichmannpas/... compatible with Python 2 in my fork?
    - just to understand what I recently did...
  • 1
    Yes, it was intended for python 3, so I guess your fork is compatible with python 2, congrats!!

    Python doesn't 'guess', because it already knows what type it is. In fact you can change it's type whenever your want. E.g.
    Test = "Hello, world!"
    Test = 10

    Will work.

    So yeah. Your fork is a python 2 version. Nice!

    Also I'm glad I could help a fellow Dev.
Add Comment