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年初,不知道是否绝版了……
Windows下安装Web.py快速指南的更多相关文章
- Windows下Nginx+Web.py+FastCGI服务搭建
在搭建之前,有必要了解下什么是fastcgi,但鉴于我自己也不大了解,这里就不搬门弄斧了,请参考各种百科和官网资料. 1.资源下载 python下载地址:戳这里webpy下载地址:戳这里flup下载地 ...
- 使用PuTTy在CentOS下安装web.py与简单的文件传输
两周前,出于帮朋友忙的目的,尝试了一下微信公众号的菜单自定义与自动回复功能的实现,成了. 两周后,需要将代码转移至朋友新购的服务器上,发现基本操作全忘记了,麻瓜!所以记一笔,希望也能对大家也有帮助. ...
- windows下安装web服务器
有条件下还是在linux下部署.window上真心问题挺多的. 推荐安装Visual-NMP,轻量级.组件升级方面等. Nginx绑定IPv4和IPv6的方法 listen 80; listen [: ...
- 【转】linux和windows下安装python集成开发环境及其python包
本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...
- windows下python web开发环境的搭建
windows下python web开发环境: python2.7,django1.5.1,eclipse4.3.2,pydev3.4.1 一. python环境安装 https://www.pyth ...
- (转)windows 下安装配置 Nginx 详解
windows 下安装配置 Nginx 详解 本文转自https://blog.csdn.net/kingscoming/article/details/79042874 nginx功能之一可以启动一 ...
- QT学习之windows下安装配置PyQt5
windows下安装配置PyQt5 目录 为什么要学习QT 命令行安装PyQt5以及PyQt5-tools 配置QtDesigner.PyUIC及PyRcc 为什么要学习QT python下与界面开发 ...
- Windows下安装Django【转】
Windows下安装Django及WEB服务启动 如果使用的是 Linux 或 Mac OS X ,系统可能已经预装了 Python .在命令提示符下 (或 OS X 的终端中) 输入python ...
- linux和windows下安装python拓展包及requirement.txt安装类库
python拓展包安装 直接安装拓展包默认路径: Unix(Linux)默认路径:/usr/local/lib/pythonX.Y/site-packagesWindows默认路径:C:\Python ...
随机推荐
- 20145331《Java程序设计》第1周学习总结
20145331<Java程序设计>第1周学习总结 教材学习内容总结 第一章 1.java的三大平台分别为java SE.java EE.java ME,其中java SE是基础. 2.j ...
- Java 面试题代码类收集
long temp=(int)3.9; System.out.println(temp); temp%=2; System.out.println(temp); 3 1 Java里面类的方法名可以与类 ...
- [BZOJ]BST again
Description 求有多少棵大小为n的深度为h的二叉树.(树根深度为0:左右子树有别:答案对1000000007取模) Input 第一行一个整数T,表示数据组数. 以下T行,每行2个整数n和h ...
- oracle的 分表 详解 -----表分区
此文从以下几个方面来整理关于分区表的概念及操作: 1.表空间及分区表的概念 2.表分区的具体作用 3.表分区的优缺点 4.表分区的几种类 ...
- 【ACM】求高精度幂
题目来源:http://poj.org/problem?id=1001&lang=zh-CN 求高精度幂 Time Limit: 500MS Memory Limit: 10000K To ...
- SQL映射文件-----MySQL关系映射【1对1,1对多,多对多】
SSM框架下,mapper.xml 中 association 标签和 collection 标签的使用 当数据库中表与表之间有关联时,在对数据库进行操作时,就不只是针对某一张表了,需要联表查询 My ...
- java HTTP代码示例
//测试环境发送用例 @Test public void testSendForTest() { String url = "http://172.16.30.108:8138/ap ...
- Build hadoop 2.5.2 with Java8
mvn clean package -Pdist,native -DskipTests -Dtar -Dmaven.javadoc.skip=true
- [转载]查看JDK及Java框架的源代码
1.点 "window"-> "Preferences" -> "Java" -> "Installed JRE ...
- 使用Netty做WebSocket服务端
使用Netty搭建WebSocket服务器 1.WebSocketServer.java public class WebSocketServer { private final ChannelGro ...