Sunday, January 30, 2011

How can I run eBay Python samples on Windows?

Summary
Python samples on how to access the eBay Trading API are available here. Before you run the Python samples on a Windows environment, you may have to configure the environment properly. You need to configure a Web Server (like Apache) to run Python code as CGI scripts. The following section explains how.


Detailed Description
To begin with,
i) Download and install Python for Windows from here.
ii) Download and install Apache Web Server from here.

From this point on, this article assumes that your Python and Apache installations are independently working properly. 

The following are some quick steps to configure your Apache Web Server to run Python code:
i) Open your httpd.conf file located in the "conf " directory in the Apache installation directory.

ii) Find the line which looks like this:
Options Indexes FollowSymLinks
iii) Add the command ExecCGI to this line. After you do so, the line should look something like this:
Options Indexes FollowSymLinks ExecCGI
iv) Next, look for a line similar to this:
#AddHandler cgi-script .cgi
v) Uncomment this line by removing the # in front of the line, and add a .py to the end of the line. Ensure the line looks something like this after the change:
AddHandler cgi-script .cgi .py
vi) Save and close the httpd.conf file and restart your web server. Your web server is now ready to execute Python code as CGI scripts. Running the code sample:

To run the code sample, place the sample files in the "cgi-bin" directory located in the Apache install directory. The first line of your .py file should always point to the location of your Python installation. Open your .py file and add the following line to the first line of .py file (ensure it points to the actual path to Python installation on your machine):
#!C:/Python26/python
Open the browser and run your sample by entering the URL similar to the following format :
http://localhost/cgi-bin/GetItem.py
Note: Follow steps in the "README.txt" shipped with the sample before you run the sample in the browser

No comments:

Post a Comment