在 Windows 平台上的 Xampp 上运行 Python 代码 [英] Running Python Code on Xampp on windows platform

查看:40
本文介绍了在 Windows 平台上的 Xampp 上运行 Python 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XAMPP-PYTHON-WINDOWS

我已经安装了 Xampp.我正在运行 apache web 服务器和 mySql 服务.我想在我的网络服务器上托管我的 python 代码.但是,我很难用 Xampp 设置 python.我阅读了有关 modwsgi 的信息,将其下载并粘贴到模块文件夹中.我的 C 驱动器上安装了 python 3.2.

I have installed Xampp. I'm running the apache web server and mySql service. I want to host my python code on my web server. However, I am having a hard time setting up python with Xampp. I read about modwsgi, downloaded it and pasted it in the modules folder. I have python 3.2 installed on my C drive.

请让我知道我接下来应该做什么,比如我应该在哪里粘贴我的 python 文件以及我应该如何通过网络浏览器执行它们?我应该能够做到这一点:

Please let me know what should I do next, as in where should i paste my python files and how should I execute them through a web browser? I should be able to do this:

http://74.xxx.xxx.xx/python/test.py (localhost/python/test.py)

http://74.xxx.xxx.xx/python/test.py (localhost/python/test.py)

这应该执行python代码.

and this should execute the python code.

当我尝试执行上述操作时,我明白了:

When I try to do the above, i get this:

服务器错误!

服务器遇到内部错误,无法完成您的请求.服务器过载或 CGI 脚本中存在错误.

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

如果您认为这是服务器错误,请联系网站管理员.

If you think this is a server error, please contact the webmaster.

错误 500

74.194.129.162011 年 3 月 2 日凌晨 2:11:16Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1

74.194.129.16 3/2/2011 2:11:16 AM Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1

非常感谢所有帮助.

推荐答案

mod_wsgi 的官方版本不支持 Python 3.2,所以你不能使用它.要使用 Python 3.2,您需要从 subversion 存储库中的源代码编译 mod_wsgi,我建议这可能会超出您根据上述问题所能做的范围.因此,请使用 Python 2.6/2.7.另见:

The official releases of mod_wsgi don't support Python 3.2 so you cant use it. To use Python 3.2 you would need to compile mod_wsgi from source code in subversion repository which I would suggest is probably going to be a bit beyond what you are able to do based on problems you are having above. So, use Python 2.6/2.7. Also see:

http://code.google.com/p/modwsgi/wiki/InstallationOnWindowshttp://code.google.com/p/modwsgi/wiki/DownloadTheSoftware?tm=2#Windows_Binary_Downloads

正如 Daniel 建议的那样,我建议您使用 Flask.你也可以使用 web2py,这是另一个对新手来说很容易的框架.我还建议,如果您刚刚开始学习这些东西,请不要使用 Apache/mod_wsgi,而只需使用您使用的 Python Web 框架提供的内置开发服务器.如果您对 Apache 一无所知,那么最初这将为您省去很多麻烦.

As Daniel suggested I would suggest you use Flask. You could also use web2py which is another framework which is easy for newbies. I would also suggest that if you are only starting to learn this stuff that you not use Apache/mod_wsgi and instead just use the inbuilt development server provided by the Python web framework you use. That will save you a lot of headaches initially if you know nothing about Apache.

这篇关于在 Windows 平台上的 Xampp 上运行 Python 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆