flup安装问题

在windows下flup一直安装不上,不知道为什么,在linux下面安装一次就成功了~~
同样的安装方式,网上搜索了半天,都是一笔带过,都没有说怎么在Windows下具体的安装方式,找到一个也碰到我这样的问题的帖子,但没有解决办法,很郁闷耶~~~
安装方式如下(python版本为2.5):
从网站上下载flup-1.0.1.tar.gz版本,解压缩至c盘,然后进入到解压缩的目录,在dos下执行python setup.py install 命令,执行完后在python环境下输入import flup.server.fcgi_fort ,报错,具体错误如下:
>>> import flup.server.fcgi_fort
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named fcgi_fort

执行from flup.server.fcgi_fork import WSGIServer,也报错,错误信息如下:
>>> from flup.server.fcgi_fork import WSGIServer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win32\egg\flup\server\fcgi_fork.py", line 56, in <module>
File "build\bdist.win32\egg\flup\server\preforkserver.py", line 53, in <module
>
ImportError: Requires eunuchs module for Python < 2.4

没有看懂这些信息,下班后回去再试一下~~~

难道是传说中的操作系统因素,公司的电脑是win2003的~~

回去后用xp试试~~~

试了一试,好像是版本不一致,在windows xp下安装,也报上面的错误,
后来又试了一下其它的文件,如:import flup.server.scgi,import flup.server.fcgi_base都是正确的~~~
现在还不清楚为啥装不上~~~
继续查原因~~~

由import flup.server.fcgi_fork这个产生的错误信息进入到preforkserver.py文件

确认了是from flup.server.preforkserver import PreforkServer这句出错

再通过import flup.server.preforkserver这个产生的信息知道了是import eunuchs.socketpair这句抛出了异常,异常信息如下:
raise ImportError, 'Requires eunuchs module for Python < 2.4',好像是需要eunuchs相应的东东,

eunuchs从网上下载下来了,但里面的文件又是以.so结尾的文件,
需要用到ctypes 模块(需要去google上搜),它提供跨平台的动链接库的直接调用。windows下是dll,*nix下是.so或.sl吧。
哎~~~~这个貌似又是linux下的东东,都不知道该怎么弄了~~~

http://code.djangoproject.com/ticket/8742这篇文章上写了一些相关的信息,如下:
Django FastCGI cannot be used on Windows, and possibly other non-Unix environments.

Currently the FastCGI feature of Django (manage.py runfcgi) relies on the Python library 'flup', which relies on Unix-only socket functions (socket.socketpair(), socket.fromfd(), etc.) making it impossible to use the FastCGI feature of Django on non-Unix envs like Windows, and hence, making it impossible to serve Django with non-Apache (non-mod_python) httpds like lighttpd on non-Unix envs.

Possible solutions: The function socketpair() is unofficially implemented on Windows by a recipe. (http://code.activestate.com/recipes/525487/) Committing this patch to the flup project is not a hard work. However, the function fromfd() has nothing like that. There is a patch enabling its Windows use (http://bugs.python.org/issue1378) but the patch is not yet applied on the Windows release, even on Python 2.6b2. Rewriting the FastCGI feature with python-fastcgi (http://pypi.python.org/pypi/python-fastcgi) could be a more work than flup, but then the feature can support Windows.

Unix environments, especially GNU/Linux, is of course better than Windows to be used as a web server, but there are some situations where Windows and FastCGI have to be used. It would be good to have Django FastCGI available on Windows.


进入到http://code.activestate.com/recipes/525487/这个网址,把上面的代码复制到preforkserver.py中,把下面的代码删掉:
try:
import eunuchs.socketpair
except ImportError:
# TODO: Other alternatives? Perhaps using os.pipe()?
raise ImportError, 'Requires eunuchs module for Python < 2.4'
把def socketpair()方法下的 s1, s2 = eunuchs.socketpair.socketpair()修改为s1, s2 = SocketPair,之后在python环境中输入import flup.server.fcgi_fork,就没有出错了

这样终于没有报错了,但新的问题又出现了~~
执行下面的语句:
python manage.py runfcgi method=threaded host=127.0.0.1 port=8050 daemonize=false
在浏览器中输入http://127.0.0.1:8050/,貌似一直在请求,但得不到结果,不知道是什么原因,什么提示也没有
ps:在更改flup的东西以前执行上面的语句和之后得到的结果一致(极有可能是修改有误,不知道别人是怎么在Windows下安装flup的,新手的困惑啊)~~~
哎~~~~~~~~~~~~~~~~~~~~~
怀疑最初的想法是否正确~~~


附件为flup-1.0.1.tar.gz
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值