简体   繁体   中英

How to install Python for Apache on Windows?

I'm looking for the fast, easy (all default settings) way of installing Python on my windows machine so that Apache can use it. I currently have a Windows 7 installation with Apache and PHP working. I want to try and make some simple web pages in Python, just to play around with Python for a bit and learn a thing or two. I downloaded and installed Python 3.2 Python 2.7.2 (As advised below). What do I do next? I would like to make a "Hello World". Do I need mod_python or can I do without? I assume I need to tell Apache somehow that Python is available. I probably need to make an "index.py" file, or something similar?

I'm not directly looking for tutorials on the Python language itself, but just for some steps to make the simplest of the simplest script (Hello World) work on my current system.

Basically I'm looking for the Python equivalent of the following php script to work in my Apache:

<html>
 <head>
  <title>Hello World</title>
 </head>
 <body>
  <?= "Hello World"; ?>
 </body>
</html>

First of all, especially in the web sector it's better to stay with python 2 (2.7) for now. Lots of frameworks and libraries are not py3-ready yet.

Then you might want to use mod_wsgi instead of mod_python which is deprecated and not available in binary form for recent python versions (and using old python versions such as 2.5 is bad).

Finally, unlike PHP it's usually not a good idea to write python webapplications with the idea of 1:1 mappings between files and urls. To get started with something nice, have a look at the Flask microframework . It has some good examples and a full tutorial. And to make it even better, you don't need Apache for it during development as you can simply run a python-based developmont server.

You can use mod_python (deprecated and not recommended) or better mod_wsgi .

Look at:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM