Thursday, March 25, 2010

Easy way to install python packages on windows

Those who worked on debian linux must be knowing apt-get tool for python package installations.It requires a single line command

apt-get install python-package

It take care of all dependecies, download it from repository and install it.

There is a simple way to do this on windows too. No need to spend time searching packages and their dependencies for windows, downloading and unzipping them.

What you require is python setuptool for windows. Download suitable .exe installer (Check for python version) and run it. It will get installed and will create 'easy_install.exe' installer in python directory 'Scripts' (In my case it is in "C:/Python25/Scripts")

Write down this path somewhere or just keep in mind. Next thing to do is to change system variables.

To do this:

1. Right click My Computer go to Properties
2. Go to tab Advanced click on Environment Variables
3. In System Variables select Path and click on Edit
4. Append previously wrote (remembered) path to Variable value click Ok. (This allows you to run easy_install from any directory. You can separate path variables by semicolon)

and you are done.


You can now directly install python packages from command line by simply entering

easy_install python-package

Here I did it for PIL (Python Imaging Library)



It will look for dependencies if any and will install them prior to pacakge installation.

So next time onwards no need to worry about finding right dependencies, downloading and installing them. Just one command enter and wait of few minutes will do it for you.

Friday, January 29, 2010

IE bug fight experience

Today finished with basic functionality of file browser which allows user to upload/ download file and share it among users based on roles and group/ category.
It was quite a task and IE added to it by behaving exactly same as what I heard or read on web. :-(
The issue was not new, but an innerHTML property failure of IE. Though not standard, innerHTML property works fine on most browsers other than IE [IE have to keep it's individuality ;-)].

Let's see what had happened.
In my code I had 3 DOM objects which I would append to parent element one at a time depending on scenario.
Before appending new object to parent element I cleared the parent content by setting innerHTML to blank.

parent.innerHTML = ''
parent.appendChild(new_object)

It worked fine in other browsers but in IE.The object was not rendering on the page.
It was a time to get experts help so posted a topic to ORKUT community. The immediate reply I found of a moderator saying not to use innerHTML in DOM, instead use removeChild to clear content of parent element.
Although unsure of solution, hint was worth trying. Atleast it was proper way of coding DOM as he said.
To clear parent content I did the following.
var len = parent.childNodes.length;
if(len){
    for(l=0; l<len; l++){
        parent.removeChild(parent.childNodes[0]);
    }
}
and next step was to append new object
parent.appendChild(new_object);

I quickly refreshed browser (IE offcourse) and checked for all scenarios. To my surprise it worked perfectly.
My first IE bug fight experience, before that it was all heard or read fairy tales of IE bugs.