Search code examples
pythonwebapp2httpserversix

Webapp2 ImportError: cannot import name _thread


I am trying to start webapp2 development server from terminal but I get this error

> File "/Users/mertbarutcuoglu/Desktop/hellowebapp2/main.py", line 12,
> in main
>     from paste import httpserver   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paste/httpserver.py",
> line 29, in <module>
>     from six.moves import _thread ImportError: cannot import name _thread

And this is the python script:

import webapp2

class HelloWebapp2(webapp2.RequestHandler):
    def get(self):
        self.response.write('Hello, webapp2!')

app = webapp2.WSGIApplication([
    ('/', HelloWebapp2),
], debug=True)

def main():
    from paste import httpserver
    httpserver.serve(app, host='127.0.0.1', port='8080')

if __name__ == '__main__':
    main() 

Solution

  • There seems to be an issue running this on Mac OS systems. See

    https://github.com/pypa/pip/issues/3165

    to fix, i had to uninstall paste i.e sudo pip uninstall paste then ran, sudo pip install paste --ignore-installed six