0

I am new to Python and am trying to run a very simple Python script on a web page, using the tutorial on web.py. When I installed web.py through the terminal it said it installed successfully, but when I try to run hello.py I get the following error messages (screenshot and text below), and nothing opens on my localhost. error message

----------------------
CODE FROM WEB.PY
----------------------

import web

urls = (
  '/', 'hello')

app = web.application(urls, globals())

class hello:
    def GET(self):
        return 'Hello, web!'

if __name__ == "__main__":
    app.run()

ERROR MESSAGE

The above is a description of an error in a Python program, formatted for a Web browser because the 'cgitb' module was enabled. In case you are not reading this in a Web browser, here is the original traceback:

Traceback (most recent call last): File "hello.py", line 1, in <module> import web File "/Users/swanstro/Desktop/web/init.py", line 14, in <module> import utils, db, net, wsgi, http, webapi, httpserver, debugerror File "/Users/swanstro/Desktop/web/wsgi.py", line 8, in <module> import http File "/Users/swanstro/Desktop/web/http.py", line 16, in <module> import net, utils, webapi as web File "/Users/swanstro/Desktop/web/webapi.py", line 31, in <module> import sys, cgi, Cookie, pprint, urlparse, urllib File "/Users/swanstro/Desktop/cgi.py", line 22, in <module> form = cgi.FieldStorage() AttributeError: 'module' object has no attribute 'FieldStorage'

Any help would be welcome. Thanks.

1
  • You should copy and paste your traceback into your question. Also include the code example so that someone might be able to spot what is wrong Commented Jul 16, 2016 at 15:56

1 Answer 1

1

It looks like you have a file named cgi.py (/Users/swanstro/Desktop/cgi.py) that is conflicting with the Python standard library cgi module when you try to import cgi. Try renaming cgi.py to something else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.