Thursday, July 24, 2014

Installing Python 2.7 / 3.4 on Windows

Start Learning Python!!!


This blog post is for installing Python on Windows. This method doesn't use Eclipse Indigo IDE installation, so you don't have to worry about all the settings, preferences. This installation will hardly take 5-10 minutes and in no time you can start learning Python - a very powerful, easy to learn scripting language which is preferred by both technical & non-technical people who want to learn programming.

So lets start, first we need Python. To install Python, click here. Depending on your Operating System (OS), select either Python 2.7 or Python 3.4.

As on 7/24/2014 - the current versions are Python 2.7.8 and 3.4.1. 

Click on the Windows version (32 / 64 bit).

Screenshot of Python downloads page

Once you have downloaded the version relating to your OS, find the downloaded file. Double click on the executable file.

You may be prompted to proceed with the installation. Click Yes.

Follow the installation instructions. Accept defaults. Keep it Simple! :)

Once you've installed Python, Download notepad++. You can download it here.

Again, locate the file and install the program. We will be using Notepad ++ as an IDE for writing Python Programs.

Finally, we have one more step. Open Windows Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework.

To open this, Click on the Start button, and start typing Powershell. Click on Windows PowerShell.

Screenshot of Windows PowerShell
Type in Python. You should see as shown below:

Screenshot of python command in Windows PowerShell

If in case, you get an error saying python is not recognized. Copy and paste the following code:

[Environment]::SetEnvironmentVariable("Path","$env:Path;C:\Python27", "User")

Note: If you have Python 3.4 installed then the path will be Python34 instead of Python27.

After this is done, type python again. It should recognize, if not close PowerSehll and Open it again and type Python. (In some cases, restart might be required)

After this press CTRL + z

You may want to create some directory using the mkdir command. For example "mkdir python_programs" and then hit ENTER.

Change to python_programs directory by "cd python_programs"

Open notepad and new file.

Type in the following code:

print ("Hello World, This is Python!");
print("I will master python!!!");

Save the file as hello_world.py

Then go to PowerShell and execute the python program by typing:

 "python hello_world.py"

You should be able to see the output in Windows PowerShell.


Output of Hello world program
That's it :) You are officially a Python Programmer.

Hope your python experience turns out great.




No comments:

Post a Comment