Windows下安装Web.py快速指南

原创 2017年07月19日 14:04:55

环境介绍

首先介绍下安装使用的环境
- 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年初,不知道是否绝版了……

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

web.py 安装

一、下载web.py

简单而直接的Python web 框架:web.py

web.py 是一个Python 的web 框架,它简单而且功能强大。web.py 是公开的,无论用于什么用途都是没有限制的。而且相当的小巧,应当归属于轻量级的web 框架。但这并不影响web.py ...

简述安装web.py框架及初次使用概述

前两天学习爬虫,感觉自己对网页的结构不够了解,不了解如何建站,其次就是正则表达式的应用很棘手,今天顺便花点时间了解了下web框架,初次学习使用,记录下重点内容,方便日后重新回顾和加深学习。 启程: ...

access+asp 手注

(本人小白一枚这是我的第一篇博客,想分享自己的一些学习路程,也希望能够在这里见证我成长的一点一滴。) 首先,在虚拟机搭建好环境。 然后测试是否存在注入点。输...

在windows下安装webpy

[prerequisite] 1. install python http://www.python.org/getit/releases/2.7.3/ 2. download webpy h...

在Windows x64位环境上搭建web.py+apache2.4+wsgi的网站

apache24 windows x64 web.py wsgi
  • rav009
  • rav009
  • 2016-10-11 12:31
  • 1097

web.py的安装说明

web.py的安装说明 1、web.py简介 web.py是一个基于Python,简单而又强大的开源Web框架。 由于自己总是对轻量级的东西比较偏爱。因此选择了web.py来学习Web开发...

python web py入门-1-web.py简介和安装

背景         记录python web.py开发入门学习的过程,主要想通过这个入门,然后继续去学习python Django框架开发课程。目前我的个人技能状态是,稍微懂点selenium we...

web.py指南性说明

web.py指南性说明 作者: phithon 分类: Python 时间: 2014-5-30 10:51 评论: 4条评论 浏览: 4795人看过 标签: web.py  ...

Win7安装Web.py,UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in

突然想看看Webpy, 在网上看到一个篇:在windows下如何快速搭建web.py开发框架
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)