aws-samples / amazon-rekognition-video-analyzer

A working prototype for capturing frames off of a live MJPEG video stream, identifying objects in near real-time using deep learning, and triggering actions based on an objects watch list.
Other
367 stars 157 forks source link

No module named http.server #62

Open foocp opened 2 years ago

foocp commented 2 years ago

Followed the instructions using Mac OS Monterey, which required installing Python 2.7 from scratch. OpenCV works fine now, which took most of the time. However, when I do pynt -l (or any pynt command) I get


Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/pynt", line 11, in <module>
    load_entry_point('pynt==0.8.2', 'console_scripts', 'pynt')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pynt/_pynt.py", line 298, in main
    build(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pynt/_pynt.py", line 48, in build
    module = imp.load_source(path.splitext(path.basename(args.file))[0], args.file)
  File "build.py", line 15, in <module>
    import http.server
ImportError: No module named http.server

Same if I try python build.py. Now if I understand this correctly, http.server may not work at all with Python 2.7. Is that right? Then what to do?

foocp commented 2 years ago

OK, seems this works to get the webserver starting on Python2. Amend build.py:

# import http.server #won't work on python2, instead use
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
#import socketserver #all lower case is Python3, so use
import SocketServer
#add:
from SimpleHTTPServer import SimpleHTTPRequestHandler

and then further down amend the def webuiserver part

def webuiserver(webdir="web-ui/",port=8080):
    '''Start a local lightweight HTTP server to serve the Web UI.'''
    web_build_dir = 'build/%s' % webdir

    os.chdir(web_build_dir)

    Handler = SimpleHTTPRequestHandler

    httpd = HTTPServer(("0.0.0.0", port), Handler)

    print("Starting local Web UI Server in directory '%s' on port %s" % (web_build_dir, port))

    httpd.serve_forever()

    return

This then gets everything working without any error messages. However, the dashed area in the Web UI still won't populate with the captured images. The browser's console just indicates "length = 0". Any ideas where to look for the error?