1
import web

ImportError: No module named web

in below code:

import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'world'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()
Constantinius
  • 34,183
  • 8
  • 77
  • 85
anbu jeremiah
  • 111
  • 1
  • 2
  • 6
  • possible duplicate of [how to import / add module named utils in python](http://stackoverflow.com/questions/8400866/how-to-import-add-module-named-utils-in-python) – David Webb Dec 06 '11 at 14:32
  • Have you solved your issues? Where any of the given answers useful to you? If so, please upvote the useful ones, and eventually select as accepted the one that solved your problem (if any). :) – mac Dec 09 '11 at 20:04

2 Answers2

3

Is Webpy installed in a directory on your Python path? Have a look at what directories are included by...

import sys

print sys.path

It is better to install third-party packages using something like pip or easy_install - this usually avoids path issues.

sudo easy_install web.py

But if you absolutely can't do this (you are making life difficult if you don't), then you can hack around it by including something like

>>> sys.path.insert(0, '/path/to/webpy') 

Though this his is frowned upon.

ZenGyro
  • 176
  • 1
  • 6
0

It seems like the module web cannot be found. It is neither located in your standard package directories (depends on your python version) nor in a location referenced by your PYTHON_PATH environment variable.

Additionally there is no file web.py relative to your script.

Did you install all dependencies correctly?

Constantinius
  • 34,183
  • 8
  • 77
  • 85