Search

Python Logo

Python On Windows XP: 7 Minutes To “Hello World!”

Instead of being all things to all users, this little how-to assumes the following:

  • You are a Windows XP user who is curious about computer programming;
  • You would like to install the Python computer language on your Windows XP machine, start the Python interpreter, and run the classic “Hello World!” program.

(Any Vista users? You can help by leaving a note about any differences you encounter while following these instructions on Vista. Thanks, rd)

If you have questions, like “What is Python and why should I install it on my Windows XP computer?” go read Why Python on Windows XP? Come back if you want to install Python.

Back already? Never left? Okay, proceed.

A company called ActiveState makes a free, all-in-one Python distribution that has everything you need to run Python on Windows XP, with all of the “hooks” you’ll eventually want to control your Windows machine and Windows programs using Python.

I don’t work for ActiveState. I am not an affiliate. There is no affiliate id or code in the link I provide to their site. I get no fee or percentage from them. I am not a computer expert, nor am I a computer scientist, just a Python fan.

Ready? Assuming you have cable or DSL, you are less than seven minutes away from having Python installed on your computer and typing your first command at the interpreter prompt. Go!

  • Open another browser window (so you can keep reading this one) by pressing shift-and-click on the: ActivePython page of the ActiveState site.
  • You are on the ActivePython page. See the “Choose From” menu box, where the first choice is “ActivePython”? Next to it is a little blue Download button. Click on it.
  • Now a form appears where, if you wish, you may give ActiveState your name and email address. It’s not required. If you comply, you may receive one or two emails a year telling you about new distributions. If in doubt, skip it, come back later and sign up. Click “Continue“.
  • Now you’re on a page where you get to choose from a dozen different Python installations, just in case you are an Alpha Geek interested in installing Python on your Solaris Sparc WorkStation, your Slackware distro, or your AMD64 desktop. If you’re an Alpha Geek, you know which one to install, right? But you’re not an Alpha Geek (yet), you’re an average Windows XP user, right? So you want the newest version (2.5.1.1) and click on the one that says: “Windows (x86) (21.2 MB).” The actual link is the little “MSI” underneath.
  • Download this file and make a note of where you store it on your computer. It takes a few minutes to complete the download. Pass the time by recalling the “Bring Out Your Dead” scene from The Holy Grail. Done? Okay, go find the ActivePython file on your computer.
  • As of this writing, the file you downloaded is called “ActivePython-2.5.1.1-win32-x86.msi.” It’s about 21 megabytes, which is half the size of the last driver I installed for my Logitech Mouse.
  • Double-click on the ActivePython file.
  • Up pops the ActiveState box and tells you it’s going to install ActivePython. Click Next.
  • Up pops the Licensing Agreement. Check the Accept box. Click Next.
  • Up pops a dialogue box allowing you to customize the installation. Don’t customize it. Click Next.
  • See the button that says “Install”? Click it.
  • You’re done, and the ActivePython User Guide appears.
  • Now go to START | All Programs | ActiveState ActivePython 2.5.
  • The menu will break out into submenus. You want the one that says: “Pythonwin Editor.” Click on it.
  • You are now at the command prompt of the Python interpreter and ready to speak Parseltongue.
  • Your cursor will be blinking just to the right of a prompt that looks like this: >>>
  • Type the following command there and make sure that “Hello World!” is inside quotation marks:
    >>> print “Hello World!”
  • Press Enter. You should see Hello World! appear in a different-colored font on the line below.
  • If so, you’re done!

Python Logo

You are inside the interpreter of the Pythonwin IDE (Integrated Development Environment). Leave the Python interpreter open, ready, and waiting to take your commands. Go to one of the following tutorials, which will teach you how to use the Python interpreter to learn Python:

  • Learning To Program (if you’re in a hurry to type more commands into the interpreter, go straight to the “Simple Sequences” section of Professor Gauld’s justifiably famous tutorial).
  • A Beginner’s Python Tutorial. Steven Thurlow wrote this simple, excellent tutorial for the modding community of Firaxis’ Civilization. Useful to beginners with little or no programming knowledge.
  • Python Baby Steps Tutorial (a new, well-made tutorial that walks you through the basics of using the Python IDE to interact with the Python interpreter, or to make your first Python scripts).
  • One Day of IDLE Toying (made for a slightly different version of the IDE, but most instructions work fine with the Pythonwin IDE).
  • A Byte of Python (Keeps getting better. Now available on an easy-to-read wiki. It’s geared toward an IDE used on both Linux and Windows, so ignore the Linux instructions).

Once you become comfortable playing with the Python Interpreter, go to the BeginnersGuide/NonProgrammers page of the Python.org site and select more tutorials. There are plenty of good ones. All free!

Later, when you start learning to program and have more questions, visit the Python Users Group at Google Groups and search it. Chances are your question has already been asked and answered. Also, refer to this excellent Python Quick Reference sheet when you need help remembering commands.

If you prefer learning from a good Python book, try one of these two written for beginners:

After you acquire basic knowledge in Python, you can move onto some other great books:

  • The Python Cookbook, 2nd Ed., by Alex Martelli, et. al, which provides “recipes” for common tasks you might like to accomplish using Python on your computer. For many people, this is the best way to learn code, by studying examples contained in programs that do useful work.
  • Learning Python, 3rd Ed., by Mark Lutz, commonly considered the most thorough introduction to the language for beginners, now out in a new 3rd edition that covers Python 2.5 and looks ahead to Python 3.0.
  • Python: Essential Reference, 3rd Ed., by David M. Beazley. This is the newest of the Python books and probably the best all-around Python book, but newbies may find it overly terse. Beazley wastes no words and has a tight, crisp writing style. If you are already familiar with basic programming concepts, but are new to Python, Beazley is your man.

Have fun!

Richard Dooling

52 Responses to “Python On XP: 7 Minutes To “Hello World!””

1. Why wouldn’t you just download the official Python windows installer http://www.python.org/download/ ? It seems a little bit pointless to use Activestate’s repackaged version when you could get the official version from the creators in a Windows-friendly format.

2. Another good reference for Python beginners is located at: http://www.ibiblio.org/obp/thinkCSpy/

Brendan,

Does the Python.org version include the Mark Hammond Win32 extensions? Don’t they have to be installed separately? I thought this came up once on the Python boards, and people told me they were two separate downloads.

The idea here is to get Python downloaded and installed for the user who is perhaps intimidated by a big shaggy page of versions, bug fixes, and multiple downloads.

Rick

I timed it at two minutes (and a bit) dead!

Excellent stuff!

Dude, that was awesome. And only took 3 minutes.

Great. Thanks for that.

By the way.. What are you using in WordPress to get the bullet points in the post? I have been looking for something like that for a while.

Thanks.

Scratt,

What am I using to get bullets? I’ll check the css tomorrow and see if I can find it. If you are are a WordPress user, you can poke through the Wuhan download. That’s what I made it from. I did a lot of work on the sidebar and header, but the post code should be just the way you find it in the Wuhan theme download. See if you can find what you need there.

http://wuhan.authenticasian.com/

Rick

pythonwin != IDLE . idle is the funny little (python/tk programmed) python “ide” that comes with the official download.

But you are right to use Activestates distribution, because the IDE is way better than idle and they include the win32 extension and the rest is the same.
If you want to seriously lern some python, check out www.diveintopython.org , the de-facto standart book on python on the web.

Oh yeah, and for a book i suggest “Learning Python” by Mark Lutz, David Ascher . I learned to love python with this book, its very good ;)

>> pythonwin != IDLE . idle is the
>> funny little (python/tk programmed)
>> python “ide” that comes with the official download.

Fixed. Whatever it is it’s Eastern Bloc ugly compared to the Pythonwin IDE :)

Rick

Why not hint at eclipse with pydev as a python ide? eclipse is also cool to write java, php, cmfl, and to some extent even fortran or c. it’s free and i guess you can set it up in 7 minutes with pydev, assuming you have a fast connection to load pydev from the update site.

Have heard great things about Eclipse (although I’m a Komodo Dragon user myself), but have not tried it . . . yet.

The Eclipse home page is at:

http://www.eclipse.org/

The PyDev home page is at:

http://pydev.sourceforge.net/index.html

Great tutorial!!
Thanks!

This was my first step to hacking and programming, thank you!

I like so much your style,
thanks for the tutorial.
See ya!

Pain free instructions, thank you very muchly. Do you know of a similar resource for how to install Webmin on Windows? Webmin’s own instructions assume too much knowledge and I’m no sysadmin.

Dear Matt:

Sorry. Not familiar with Webmin. Looks a bit dodgy for Windows. Just scanning the instructions, it looks like you need ActiveState Perl installed, along with a module and such. Seems like primarily a Linux tool? Let us know if you get it working and if it’s worth the install.

As for Python, be advised that the ActiveState distribution will upgrade to Python 2.5 soon. It’s basically just an uninstall and reinstall using the 2.5 distro. You can download 2.5 from Python.org now, but then you must install the win32 stuff separately, blah blah. Not pain free, in other words.

Just stay with 2.4 for now, especially if you’re just getting your feet wet.

I’ll post the ActiveState 2.5 instructions as soon as they come out with it.

Thanks,

rd

I’m new to python and just loaded up the 2.5 version from python.org. I didn’t even see something else to download (the win32 stuff you’re talking about). Do I really need it? What is it for?
I know those are probably the types of question that are to user specific or to broad to answer in a few sentences, but if you can I’d like to know. I guess I’ll just go get the ActivePython verson also.

Thanks,
Matt

Matt,

You don’t need the ActiveState distro, too. You just need the
extensions.

The ActiveState version is stuck at 2.43 for the moment. If you’ve got 2.5 it’s the most current. If you’d like the Windows Extensions, you can download them here:

http://sourceforge.net/projects/pywin32/

Some people prefer the PythonWin IDE to IDLE (which comes with the standard install).

You can try both.

But don’t install the old ActiveState distro on top of 2.5.

Sorry for the confusion.

rd

RD
I did not find your info until I had downloaded Python 2.5.1 from http://www.python.org/ which had IDLE (Python GUI) with it.
I would like to try the ActiveState PythonWin IDE.

1. Do I have to Uninstall Python and download it again from ActiveState to get the IDE program?

2. If I download ActiveState’s Python, am I going to get the latest version, 2.5.1?

3. Can I get the ActiveState PythonWin IDE easily and try it? How?

Thanks for your help.

Grant R.

Grant,

I think you can get almost the full effect by just installing Mark Hammond’s Win32 extensions together with your recent Python installation.

Here is the site.

http://starship.python.net/crew/mhammond/win32/

The ActivePython distro just installs BOTH Python and the win32 extensions together in a nice package, but I don’t think it’s worth uninstalling your other installation unless you are having trouble. I believe the ActiveState Python distro also sets up your environment, paths, etc. But you can also do this yourself.

I use both ActiveState on one machine and the Python.org distro on others. But then I’ve moved to Linux so I can’t say for sure about the Windows thing.

Try just installing the win32 extensions. The gui IDE is very nice compared to the dullish IDLE one.

Good luck

rd

That was excellent Richard. Thanks very much for making it so simple to follow and easily get through it.

I’m sure a lot of questions will arise, but for now I’m good..

JC

i loved this tutorial, great stuff, i have a question if you can answer it i’d be glad just send me an e-mail with the answer “i have some experience in PHP and MySQL, and i am in the process of creating my own Content Management System, but after reading about Python and seeing professional programmers recommend Python i loved to give it a try, i would like to know if Python is the right choice for a begginer like me or shall i complete with PHP? because i don’t want to waste my time, thank you”

Rami,

This is a perfect question for the comp.lang.python group. Very
active. I’m sure you would have many responses quickly. However I
predict you will not get too much sympathy for saying “I don’t want to
waste time” as most programmers will tell you to try them both.

That said. I think your question comes up a lot. If you go to
comp.lang.python and search on python and php you’ll see what I mean

http://groups.google.com/group/comp.lang.python/topics

Good luck

very good!
dude it was awesome tutorial.
thanks.
i want to contact you

Nicely done! the parseltongue hyperlink especially ;-p a very helpful tutorial dude… thanks a ton!

Not sure if this is a dumb question, but…

The instruction above says to click on the “Pythonwin IDE” submenu. Instead, I see a submenu entitled “PythonWin Editor.” Are they one in the same?

Chris,

Thanks for pointing that out. It must be new terminology in the latest Activestate distro. Yes, they are the same.

Send any other edits or suggestions as you go. I appreciate it.

rd

sir rick,
i just cant open the installer. i have an error that says ” installation package could not be opened. contact the application vendor to verify that this is a valid windows installer package. is there something wrong with my os?

Dear Ariel:

ActivePython has very good customer service, so ask them there.

Do you by any chance have your disk partitioned into logical drives, like C,D,E etc.? If so, and you downloaded to one of those logical drives, then try copying the installation file to C:\ - the root of your C
drive and double click on it there.

Hope this helps.

rd

Hi,

Just wanted to say that I’m starting out with this language. I’ve no prior experience save some dabble here and there in HTML, which I doubt will help me very much, but I’m willing to learn. Thank you for this, because I will follow the tutorial word for word, until I can get on my feet :}

-SRS

wow took longer to read the tutorial than to install.. PYTHON HERE I COME!!! =D

I have windows XP…trying to download Python getting error 2755.

Thankyou

AM,

Are you running on an encrypted drive?

See http://tinyurl.com/2eysjm

rd

This was the best installation instruction I’ve ever come across. Thanks a lot!!!! :-)

downloaded and used python for the first time yesterday and couldent have done it without you!!! it is great fun and shockingly easy once you know how thanks

fodderz

First step into the programming world. Lets see how this goes.

Very nice installation - complements to the chef!

After Python, I’ll try to modify the Zope cookery book to what I want! - do you have any suggestions for an idiot’s start to Zope?)

Chun’s Core Python Programming seems to review well on Amazon - any experience or knowledge of it?

Geoffrey,

I don’t know Zope. I just recently purchased the Django book, though, which looks very good. Also see http://www.djangoproject.com.

As for the Chun Core Python book, I don’t know it. I’ve heard good things about it. Of the ones I’ve seen lately, I guess I would go with Python: Essential Reference, 3rd Ed., by David M. Beazley. This is the newest of the Python books and probably the best all-around Python book for programmers coming from another language. Newbs may find it overly terse and should try some of the other recommended books. If you are already familiar with basic programming, Beazley is your man.

are there any tutorial for users who are profecient programmers but just not in python?

hello i am new with python. i had just read it on how to become a hacker. i am interested to know about it. i have learned my first language c++ then java. now i try for python.

i am downloading now then look for tutorial here. can you guide me?

Thanks for being genrous enough explain all this, I tried to install Python myself and got into a terrible mess!

Why there is a special download for AMD64 Processors on www.python.org available? Do I need this download if I have a “AMD Athlon ™ 64 X2 Dual Core Processor” ?

I have found the solution. The python version ‘AMD64′ is made for 64-bit-systems. I have heard that some functions in this versions don’t work.
Every windows processor should be able to work with the python version for x86 processors (also just called ‘windows’).

Thank you anyway.

Several questions here from programmers who are refugees from other programming languages. For you, the official Python Tutorial is probably your best bet:

http://docs.python.org/tut/tut.html

Also, consult the documentation section at http://python.org

Good luck,

RD

Thanks so much from a sort of Omega Geek (yeah, that far from Alpha!). I tried downloading from the python site, read tons of instructions for using Python from LINUX-like and UNIX-like operating systems but couldn’t figure out how to use the Windows command prompt or path settings to get anything out of it at all. The ActiveState download, coupled with your instructions, is just great!!

Hope to get far enough to be able to check out some of your “advanced” links!

- Petunia

Dear Petunia,

I couldn’t figure out how to use the Windows command prompt either. That’s why I made the page! Glad it helped you.

Microsoft hides the command prompt, because if their customers learn to use a shell, and learn languages like Python, then they’ll move to Linux.

Use Python and a good cross-platform text editor on Windows until you’re thoroughly comfortable. Then take an old computer and load Linux on it. I recommend either Ubuntu or Debian, but there are many other distributions.

Enjoy.

RD

This really helped a lot. The problem is that I’ve installed the recent version of Python on the python.org distro and I’ve been having problems with the interpreter. I would uninstall 2.5, but I know that they’ve made changes and added some new features. So I was wondering if Active State has version 2.5 that I could install. I’m also not quite sure if it’s “worth” uninstalling. Does it really matter what version I use?

Olivia,

Sure ActiveState has the 2.5 version. I think you’ll like the GUI better.

But now that I’m here, I see that ActiveState changed their menus and such, so I better go reconfigure!

RD

Thanks a lot. It really helped!

This really helped. I was also referring to Professor Gauld’s website about a month ago and it was great, but now I can’t access the website anymore. Is is just my computer or has the website gone??

Professor Gauld left a note on comp.lang.python (google group) saying he was having hosting problems and had copied everything to a temporary server.

Try this:

http://uk.geocities.com/alan.gauld@btinternet.com/

rd

Thanks!!

Something to say?


Bad Behavior has blocked 369 access attempts in the last 7 days.