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.




Thursday, July 10, 2014

Get a list of installed programs on your computer


Taking a list of software you have may sometimes be a pain!!
 Re-imaging your computer? Or upgrading your OS? Need to know what software you have on your computer before you upgrade, so that it can be installed again? Windows has a way of doing this. 

Note: This method only lists the software on your computer from the registry. It doesn't recover license keys for the software. To know how to do this, please check the External links given at the end of the post.

Steps:

1. Click on "Start" and type "cmd" or "command" and then right click on the command prompt and select "Run as administrator".

Screenshot of "Run as administrator" command prompt.

2. You may be prompted for a password and a prompt for User Account control asking if "you want the program to make changes". Click YES. Once you do this / enter your password, you should be able to see the command prompt window. 

Screenshot of the User Account control pop up.
Below is the command prompt window.

Screenshot of the command prompt

3. Then enter the command "wmic" and press ENTER. This will enter the Windows Management Intrumentation Command line tool and it will enter into the root. To know about WMIC tool click here.

Screenshot of the wmic command.

4. Then include the line shown below:

/output:C:\SoftwareList.txt product get name,version

Note: There is a space after txt and product; between product and get; between get and name. Make sure the spaces are correct.

IMPORTANT: In this case, we have created the file in the root directory (C:) but you can replace it with any directory path and file name ( in this case - SoftwareList.txt). If you have trouble in saving the file in your own directory path, please check "Troubleshooting and pointers" below.

After you type the command press Enter. There is no status about how long this will take but it shouldn't take a long time. When the process completes, you should be able to see the root prompt again.

Screenshot of the "get product" command.
Screenshot after the command completes.

Screenshot showing the text file "SoftwareList" in the C: Directory.
That's it :) Now you've a complete list of software on your computer. That was easy right?

Here's another screenshot of the list of software.

Screenshot of the SoftwareList.txt

Troubleshooting & Pointers:

"Invalid file name or Alias not found"

In most of the cases, the "Invalid file name" is because of administrative rights. If you're not sure if you have administrative rights, contact your IT support for assistance. If you're sure that you have administrative rights, then check if the directory exists. This command requires the directory to exist before command execution. Please note that it doesn't create the directory.

The "alias not found" occurs because of spaces in your directory path or in your file name. If you want a workaround, store the output file in a path that doesn't have spaces.

(ELSE)

Include the directory path along with file name in between quotes as shown below:

/output:"C:\Log Files\Software List.txt" product get name,version

This will resolve the problem.


External Links:


Credit to the post: Help Desk Geek 

Note: Some changes and workarounds have been added to this post by Srikkanth Govindaraajan.