Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python import web not working

So I'm getting the following error when running a script that imports web.

$ python bin/app.py
Traceback (most recent call last):
File "bin/app.py", line 1, in <module>
import web
ImportError: No module named web

I tried using easy_install web but get this error:

$ easy_install web
Searching for web
Reading http://pypi.python.org/simple/web/
Reading http://www.pythonweb.org/web/
Reading http://www.pythonweb.org/web/release/
No local packages or download links found for web
error: Could not find suitable distribution for Requirement.parse('web')

And I tried pip install web but get the following:

$ pip install web
Downloading/unpacking web
Could not find any downloads that satisfy the requirement web
No distributions at all found for web
Storing complete log in /Users/zcj90/.pip/pip.log
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.0.2', 'console_scripts', 'pip')()
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/__init__.py", line 116, in main
return command.main(initial_args, args[1:], options)
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/basecommand.py", line 151, in main
log_fp = open_logfile(log_fn, 'w')
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/basecommand.py", line 180, in open_logfile
log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/Users/zcj90/.pip/pip.log'

Any suggestions?

Code for app.py:

import web

urls = (
    '/', 'index'
)
app = web.application(urls, globals())
class index:
    def GET(self):
        greeting = "Hello World"
        return greeting
if __name__ == "__main__":
    app.run()*
like image 411
ZCJ Avatar asked Feb 16 '12 03:02

ZCJ


People also ask

Do imports carry over python?

From my understanding, when you are importing a script to run, from another script, the imports will carry over to the new script.


2 Answers

The following is the command that you need to run

$ easy_install web.py

And according to the document for lpthw (which just uses a fork of web.py), you can run :

$ pip install lpthw.web

Then to run the application you will just need to do:

$ python app.py

like image 92
twovi Avatar answered Sep 27 '22 20:09

twovi


Old question, but for people who reach this via web search, this is the command you're looking for, assuming an apt-based linux distribution like ubuntu or debian:

$ sudo aptitude install python-webpy

like image 32
whooot Avatar answered Sep 27 '22 20:09

whooot