10

Can anyone help me to set up Python to run on Wampserver. From what I've read so far you would need to use a combination of Wampser, Python, mod_pyhton, and adjustment to the Apache http.conf file. I've tried it but i belive i am having conflict when it comes to versions. Does anyone know of a cobination of versions that can work so that i can do some local python development using my wampserver? Links to the download would be greatly appreciated.

My current config: Wampserver 2.0c => Apache Version : 2.2.8 , PHP Version : 5.2.6 , MySQL Version : 5.0.51b

Chris Moguel
  • 191
  • 1
  • 2
  • 10
  • Did you ever find an answer to your question? I am looking for the same thing. – Gabriel Fair Jul 20 '12 at 00:47
  • possible duplicate of [How to install Python with Wampserver](http://stackoverflow.com/questions/8266153/how-to-install-python-with-wampserver) – T.Todua May 06 '15 at 20:46

7 Answers7

3

Do not use mod_python; it does not do what most people think it does. Use mod_wsgi instead.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
2

How about using web.py (download) or django?

They have their own web server, and you can also connect MySQL server with MySQLdb extension.

YOU
  • 120,166
  • 34
  • 186
  • 219
2

Recognising that the post asks about mod_python, I'm posting the following, in case using CGI is acceptable.

It has been a while since I got this to work, but I got CGI scripts written with Python to run under Wampserver with a couple simple things (although it didn't seem simple at the time):

  • Download and install Python if you haven't already. The standard install should let you run programs from a command prompt (which you'll need).
  • Write your Python CGI program, making the first line be #!python (or the full path to the python executable). While the first line isn't usually necessary for Python programs under Windows, Apache seems to need this so it knows the program is Python.
  • Place the program in your cgi-bin directory.

That should do it. I double checked my httpd.conf file and don't see any changes to get Python working. (This assumes you already have CGI working otherwise.)

The following simple script should tell you if you have things working:

#!python
print "Content-type: text/html"
print ""
print "<html>"
print "<head>"
print "<title>CGI Test of Python</title>"
print "</head>"
print "<body>"
print "This is a test"
print "</body>"
print "</html>"
GreenMatt
  • 18,244
  • 7
  • 53
  • 79
  • This worked on a windows 7 machine with wamp 3.0 and Python 3.5.1! I can confirm that if I take "#!python" out, it will stop working. Also, the placement (inside cgi-bin) is a must in the default configuration. After I molested ScriptAlias to look like this: `ScriptAlias / "C:/wamp30/www/"`, it started to work everywhere. The finishing tweak was to add index.py to DirectoryIndex. – Harry Pehkonen May 27 '16 at 18:25
2

Here are some instructions here: http://www.imladris.com/Scripts/PythonForWindows.html

Sean Cav
  • 133
  • 1
  • 14
1

My WSGI setup made on WAMP server 2.5, 32bits (Apache 2.4.9 32bits) with PythonWin 2.7.8 (default, Jul 2 2014, 19:50:44) [MSC v.1500 32 bit (Intel)] on win32 went on the next way.

WAMP route = C:/wamp/

Config Apache

Download 32bits mod_wsgi.so from http://www.apachelounge.com/viewtopic.php?t=5143 and place it as c:\wamp\bin\apache\apache2.4.9\modules\mod_wsgi.so

Load the wsgi module to apache in the main C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf:

LoadModule wsgi_module modules/mod_wsgi.so 
WSGIScriptAlias /API c:/wamp/www/API/code.py 

Get webpy

C:\tmp>git clone git://github.com/webpy/webpy.git
C:\tmp>python webpy\setup.py install

Test it:

C:\tmp>python
ActivePython 2.7.8.10 (ActiveState Software Inc.) based on 
Python 2.7.8(default, Jul  2 2014, 19:50:44) [MSC v.1500 32 bit (Intel)] 
on win32  Type "help", "copyright", "credits" or "license" for more information.
>>> import web
>>>

Create your application as c:\wamp\www\API\code.py

import web
urls = (
  '', 'root',
  '/(.*)', 'hello',
  )

class root:
    def GET(self):
        return "This is the root URI."

class hello:
    def GET(self, name):
        return "Hello %s from webPy." % name

application = web.application(urls, globals()).wsgifunc()

Result

Restart your apache webserver and check http://localhost/API

jshepherd
  • 900
  • 1
  • 9
  • 22
1

Step 1: Download the Python Setup https://www.python.org/downloads/release/python-350/

Step 2: Install Python

Step 3: Download the wampserver https://sourceforge.net/projects/wampserver/files/WampServer%202/Wampserver%202.4/

Step 4: Open httpd.conf file in notepad,from that location C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf

Step 5: find CTRL+F "Directory" in httpd.conf and set wamp install location in Document and Directory , where your wamp server is installed , kindly use forward slash "/" not backword "\"

A.(DocumentRoot "C:/wamp64/www")

B.(Directory "C:/wamp64/www"> )

and Replace these two line inside Directory "C:/wamp64/www">

Remove:-

Options Indexes FollowSymLinks

Add:-

AddHandler cgi-script .cgi .py

Options Indexes FollowSymLinks ExecCGI

C. Set cgi-bin location

(Directory "C:/wamp64/cgi-bin" AllowOverride None Options None...)

Step 6: Restart All Service of wamp.

Step 7: make python program but add these line at first

#!D:/paython installed/python.exe // set path where python is installed

Step 8: save program .py extension.

Step 9: run on browser using

 localhost/file_name.py
0

Wampserver doesn't have addon for python/django, but XAMPP does.

A good tutorial here:

http://jyotirmaya.blogspot.com/2008/11/xampp-python-django.html

Yada
  • 30,349
  • 24
  • 103
  • 144