Reputation: 111
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()
Upvotes: 1
Views: 3682
Reputation: 176
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.
Upvotes: 3
Reputation: 35039
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?
Upvotes: 0