16

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()*
John Bensin
  • 301
  • 2
  • 5
  • 20
ZCJ
  • 499
  • 2
  • 9
  • 17
  • I'm doing the learnpythonthehardway tutorial and the first line of the script I'm trying to run is `import web`; what should I do? – ZCJ Feb 16 '12 at 04:20
  • app.py is which type of script. Please give code of that. – Nilesh Feb 16 '12 at 04:21

7 Answers7

8

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

twovi
  • 101
  • 1
  • 4
  • This didn't work unfortunately. Here's the output: `pip install lpthw.web Requirement already satisfied (use --upgrade to upgrade): lpthw.web in /Library/Python/2.6/site-packages Cleaning up...` – ZCJ Feb 16 '12 at 04:51
  • 1
    I just ran it on my server, user `easy_install lpthw.web` and that seemed to work pretty well, might give that a shot. Sorry for the long response time. – twovi Feb 23 '12 at 05:13
6

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

whooot
  • 415
  • 3
  • 9
  • Really? `aptitude` is how you solve a problem on OS X? And with a python that wasn't installed by the system or a package manager? – abarnert Jan 09 '13 at 20:21
  • Really? My answer is not perfect for everyone, yet it will be helpful to many. Perhaps you think most users install python by hand on OS X. – whooot Jan 14 '13 at 16:49
  • No, most users use the Python that comes pre-installed with OS X. Most of those who install another Python do so by using the binary installers from python.org (or, sometimes, ActiveState or Enthought). And those who install from a package manager tend to use a package manager that actually exists on OS X, like Homebrew, rather than apt. And Homebrew explicitly does not include Python packages, recommending that you use `pip` for Python packages. So, this answer will be helpful for just about nobody. – abarnert Jan 14 '13 at 19:27
  • Perhaps you failed to notice that the question does not explicitly mention OS X. I will edit my answer to make the point that it is only valid for apt-based linux distributions. Your confrontational attitude is very helpful too. – whooot Jan 14 '13 at 20:03
  • There is no such directory as `/Library/Python/2.6/site-packages/` on linux. And when you said "Perhaps you think most users install python by hand on OS X", that clearly implied that you believed your answer would work on OS X. – abarnert Jan 14 '13 at 20:28
  • What I wanted to say is "by hand AND on os X", but I really do not give a damn anymore about your crusade against my post. – whooot Jan 14 '13 at 21:32
  • this solved it for me, I did it like this: `sudo dnf install python-webpy` – somethingSomething Jan 14 '17 at 10:05
2

You have to download source from http://webpy.org/static/web.py-0.36.tar.gz.

The steps to install web is on http://webpy.org/install.

Please follow the steps if got any error then add comments to this post or update the question.

Nilesh
  • 20,521
  • 16
  • 92
  • 148
1

Pythonweb is pretty out of date, but they still have a downloads page where you can get the most recent release. Then just do a python setup.py install

Corey Farwell
  • 1,856
  • 3
  • 14
  • 19
0

For Ubuntu OS, install python web using below command:

sudo apt-get install python-webpy
Vikrant
  • 1
  • 2
0

With pip: pip install web.py==0.40.dev0

Neeraj
  • 99
  • 3
0

The problem is that you most likely used pip install lpthw.web to install however the lpthw book is using python 2.7 so pip2.7 would fix this:

pip2.7 install lpthw.web

PrakashG
  • 1,642
  • 5
  • 20
  • 30