Python导入web无法正常工作

ZCJ*_*ZCJ 11 python sudo install pip web

所以我在运行导入的脚本时遇到以下错误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
Run Code Online (Sandbox Code Playgroud)

我尝试使用easy_install web但得到此错误:

$ 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')
Run Code Online (Sandbox Code Playgroud)

我试过pip install web但得到以下内容:

$ 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'
Run Code Online (Sandbox Code Playgroud)

有什么建议?

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()*
Run Code Online (Sandbox Code Playgroud)

小智 7

以下是您需要运行的命令

$ easy_install web.py

根据lpthw的文档(它只使用了web.py的一个分支),你可以运行:

$ pip install lpthw.web

然后运行应用程序,您只需要执行:

$ python app.py


who*_*oot 6

老问题,但对于通过网络搜索达到此目的的人来说,这是你正在寻找的命令,假设基于apt的Linux发行版如ubuntu或debian:

$ sudo aptitude install python-webpy


Cor*_*ell 1

Pythonweb 已经过时了,但他们仍然有一个下载页面,您可以在其中获取最新版本。然后就做一个python setup.py install