木小鱼的笔记

技术之海,顺势者昌;看问题,要看思路与问题实质

Windows下安装Web.py快速指南

环境介绍

首先介绍下安装使用的环境
- Windows 7
- Python 3.6

Web.py介绍

web.py是Python在Web领域一个轻量级的解决方案,所谓轻量,就是非常简单快速满足Web页面开发的需求。
首先来感受一下其轻量的程度吧:

import web

urls = (
    '/(.*)', 'hello'
)

class hello:
    def GET(self, name):
        i = web.input(times=1)
        if not name: name = 'world'
        for c in xrange(int(i.times)): print 'Hello,', name+'!'

if __name__ == "__main__": web.run(urls, globals())

综合来看,是不是非常的轻量….

安装指南

目前默认的web.py版本是0.38, 只要是针对python2而打包的,针对Python3是无法通过pip3的方式来直接安装的:
在安装之前,需要提前安装2个依赖包:

pip3 install db
pip install utils

直接安装web.py会报出若干错误信息:

C:\Users\xx>pip3 install web.py
Collecting web.py
Using cached web.py-0.38.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\CHENJU~1\AppData\Local\Temp\pip-build-vxm84t4s\web.py\setup.py”, line 6, in
from web import version
File “C:\Users\CHENJU~1\AppData\Local\Temp\pip-build-vxm84t4s\web.py\web__init__.py”, line 14, in
import utils, db, net, wsgi, http, webapi, httpserver, debugerror
File “d:\program files\python\lib\site-packages\db__init__.py”, line 69
print “var”, var
^
SyntaxError: Missing parentheses in call to ‘print’

----------------------------------------

Command “python setup.py egg_info” failed with error code 1 in C:\Users\xx~1\AppData\Local\Temp\pip-build-vxm84t
从错误信息来看,其错误为print在不同的Python版本下的语法上的差异造成的。

所以,我们直接从github上下载源代码,进行编译安装。
切换到python3的分支上,直接下载器源代码:
打开其地址: https://github.com/webpy/webpy/tree/python3

git clone https://github.com/webpy/webpy.git

待下载完成之后,进入下载目录,进行安装:

python setup.py install

结果信息:

D:\OpenSource\webpy>python setup.py install
D:\Program Files\python\lib\site-packages\setuptools\dist.py:331: UserWarning: Normalizing ‘0.40-dev0’ to ‘0.40.dev0’
normalized_version,
running install
running bdist_egg
running egg_info
creating web.py.egg-info
writing web.py.egg-info\PKG-INFO
writing dependency_links to web.py.egg-info\dependency_links.txt
writing top-level names to web.py.egg-info\top_level.txt
writing manifest file ‘web.py.egg-info\SOURCES.txt’
reading manifest file ‘web.py.egg-info\SOURCES.txt’
writing manifest file ‘web.py.egg-info\SOURCES.txt’
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib
creating build\lib\web
copying web\application.py -> build\lib\web
copying web\browser.py -> build\lib\web
copying web\db.py -> build\lib\web
copying web\debugerror.py -> build\lib\web
copying web\form.py -> build\lib\web
copying web\http.py -> build\lib\web
copying web\httpserver.py -> build\lib\web
copying web\net.py -> build\lib\web
copying web\py3helpers.py -> build\lib\web
copying web\session.py -> build\lib\web
copying web\template.py -> build\lib\web
copying web\test.py -> build\lib\web
copying web\utils.py -> build\lib\web
copying web\webapi.py -> build\lib\web
copying web\webopenid.py -> build\lib\web
copying web\wsgi.py -> build\lib\web
copying web__init__.py -> build\lib\web
creating build\lib\web\wsgiserver
copying web\wsgiserver\ssl_builtin.py -> build\lib\web\wsgiserver
copying web\wsgiserver\ssl_pyopenssl.py -> build\lib\web\wsgiserver
copying web\wsgiserver\wsgiserver2.py -> build\lib\web\wsgiserver
copying web\wsgiserver\wsgiserver3.py -> build\lib\web\wsgiserver
copying web\wsgiserver__init__.py -> build\lib\web\wsgiserver
creating build\lib\web\contrib
copying web\contrib\template.py -> build\lib\web\contrib
copying web\contrib__init__.py -> build\lib\web\contrib
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\web
copying build\lib\web\application.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\browser.py -> build\bdist.win-amd64\egg\web
creating build\bdist.win-amd64\egg\web\contrib
copying build\lib\web\contrib\template.py -> build\bdist.win-amd64\egg\web\contrib
copying build\lib\web\contrib__init__.py -> build\bdist.win-amd64\egg\web\contrib
copying build\lib\web\db.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\debugerror.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\form.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\http.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\httpserver.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\net.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\py3helpers.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\session.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\template.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\test.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\utils.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\webapi.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\webopenid.py -> build\bdist.win-amd64\egg\web
copying build\lib\web\wsgi.py -> build\bdist.win-amd64\egg\web
creating build\bdist.win-amd64\egg\web\wsgiserver
copying build\lib\web\wsgiserver\ssl_builtin.py -> build\bdist.win-amd64\egg\web\wsgiserver
copying build\lib\web\wsgiserver\ssl_pyopenssl.py -> build\bdist.win-amd64\egg\web\wsgiserver
copying build\lib\web\wsgiserver\wsgiserver2.py -> build\bdist.win-amd64\egg\web\wsgiserver
copying build\lib\web\wsgiserver\wsgiserver3.py -> build\bdist.win-amd64\egg\web\wsgiserver
copying build\lib\web\wsgiserver__init__.py -> build\bdist.win-amd64\egg\web\wsgiserver
copying build\lib\web__init__.py -> build\bdist.win-amd64\egg\web
byte-compiling build\bdist.win-amd64\egg\web\application.py to application.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\browser.py to browser.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\contrib\template.py to template.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\contrib__init__.py to init.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\db.py to db.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\debugerror.py to debugerror.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\form.py to form.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\http.py to http.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\httpserver.py to httpserver.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\net.py to net.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\py3helpers.py to py3helpers.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\session.py to session.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\template.py to template.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\test.py to test.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\utils.py to utils.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\webapi.py to webapi.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\webopenid.py to webopenid.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\wsgi.py to wsgi.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\wsgiserver\ssl_builtin.py to ssl_builtin.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\wsgiserver\ssl_pyopenssl.py to ssl_pyopenssl.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\wsgiserver\wsgiserver2.py to wsgiserver2.cpython-36.pyc
File “build\bdist.win-amd64\egg\web\wsgiserver\wsgiserver2.py”, line 1019
except socket.error, e:
^
SyntaxError: invalid syntax

byte-compiling build\bdist.win-amd64\egg\web\wsgiserver\wsgiserver3.py to wsgiserver3.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web\wsgiserver__init__.py to init.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\web__init__.py to init.cpython-36.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying web.py.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying web.py.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying web.py.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying web.py.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents…
web.pycache.application.cpython-36: module references file
web.pycache.debugerror.cpython-36: module references file
creating dist
creating ‘dist\web.py-0.40.dev0-py3.6.egg’ and adding ‘build\bdist.win-amd64\egg’ to it
removing ‘build\bdist.win-amd64\egg’ (and everything under it)
Processing web.py-0.40.dev0-py3.6.egg
creating d:\program files\python\lib\site-packages\web.py-0.40.dev0-py3.6.egg
Extracting web.py-0.40.dev0-py3.6.egg to d:\program files\python\lib\site-packages
File “d:\program files\python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\wsgiserver\wsgiserver2.py”, line 1019
except socket.error, e:
^
SyntaxError: invalid syntax

Adding web.py 0.40.dev0 to easy-install.pth file

Installed d:\program files\python\lib\site-packages\web.py-0.40.dev0-py3.6.egg
Processing dependencies for web.py==0.40.dev0
Finished processing dependencies for web.py==0.40.dev0

从结果信息来看,其中依然存在若干错误信息,对于Python3而言,这些都是在python2下的语法在Python 3下无法被正确解析的问题,估计在后续版本,可以将python2的内容在python 3的分支上逐步更新。

目前的这个分支还是dev分支,存在若干问题还是可以理解的。

总结

web.py的这位作者已经仙逝,继任者还需努力,继续更新呀,从github上最后一次提交是在2017年初,不知道是否绝版了……

阅读更多

扫码向博主提问

去开通我的Chat快问

blueheart20

博客专家

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • 架构师
  • AI手工匠人
  • 攻城狮
  • Java老兵
  • 问题解决者
版权声明:本文章是作者辛勤书写的成果,如需转载,请与作者联系,并保留作者信息以及原文链接,谢谢~~ https://blog.csdn.net/blueheart20/article/details/75370834
个人分类: 脚本语言
想对作者说点什么? 我来说一句

web.py 安装

一、下载web.py

he_jian1 he_jian1

2014-10-29 15:02:07

阅读数:8589

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭