Setting up Python in Windows 8.1

One of my family members recently acquired a Windows 8.1 laptop, and I was curious as to whether Python setup was as easy as when I wrote about installing it on Windows 7. Turns out, it is — and not much different. Which could spawn a whole conversation about Windows OS development, but that’s for another day …

Here’s your quick guide, modified from my earlier Win 7 post:

Set up Python on Windows 8.1

1. Visit the official Python download page and grab the Windows installer. Choose the 32-bit version. A 64-bit version is available, but there are compatibility issues with some modules you may want to install later.

Note: Python currently exists in two versions, the older 2.x series and newer 3.x series (for a discussion of the differences, see this). This tutorial focuses on the 2.x series.

2. Run the installer and accept all the default settings, including the “C:\Python27″ directory it creates.


3. Next, set the system’s PATH variable to include directories that include Python components and packages we’ll add later. To do this:

  • Open the Control Panel (you can find it using Search on the Charms Bar).
  • In the Control Panel, search for and open System.
  • In the dialog box, select Advanced System Settings.
  • In the next dialog, select Environment Variables.
  • In the User Variables section, edit the PATH statement to include this (if there is no PATH variable, click NEW to create one):
C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts\;

4. Now, you can open a command prompt (Charms Bar | Search | cmd) and type:

C:\> python

That will load the Python interpreter:

Python 2.7.6  (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or license for more information.
>>>

Because of the settings you included in your PATH variable, you can now run this interpreter — and, more important, a script — from any directory on your system.

Press Control-Z plus Return to exit the interpreter and get back to a C: prompt.

Set up useful Python packages

1. setuptools offers the helpful easy_install utility for installing Python packages. Grab the appropriate version for your system and install (easiest way is the ez_setup.py script).

2. pip is another package installer that improves on setuptools. Having pip and setuptools will cover most of your installation needs, so go ahead and add pip. Now that you’ve installed setuptools, you can add pip by typing the following at any Windows command prompt (not in the Python interpreter):

C:\> easy_install pip

Notice that easy_install executes without needing to be told where on the system it’s located. That’s the benefit of adjusting your PATH variable earlier.

3. Mechanize, Requests and BeautifulSoup are must-have utilities for web scraping, and we’ll add those next:

C:\> pip install mechanize
C:\> pip install requests
C:\> pip install beautifulsoup4

4. csvkit, which I recently covered here, is a great tool for dealing with comma-delimited text files. Add it:

C:\> pip install csvkit

You’re now set to get started using and learning Python under Windows 8.1. If you’re looking for a handy guide, start with the Official Python tutorial.

16 Responses to “Setting up Python in Windows 8.1”

  1. MaxHeadroom says:

    Hi thanks for the great guides!
    I’m experiencing some problems with Windows 8.1 and CSVkit. I’m sorry to ask you but I cant find any info on this particular problem anywhere on the net.

    Downloading/unpacking argparse>=1.2.1 (from csvkit)
      Could not find a version that satisfies the requirement argparse>=1.2.1 (from
    csvkit) (from versions: 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0,
    0.9.0, 0.9.1, 1.0.1, 1.0, 1.1)
      Some externally hosted files were ignored (use --allow-external to allow).
    Cleaning up...
    No distributions matching the version for argparse>=1.2.1 (from csvkit)

    Yet, when I try to reinstall argparse it says that I have the latest version of argparse.

    Do you have any idea of what is wrong or could you perhaps point me in the right direction of where I might find an answer?

  2. Anthony says:

    Max,

    Hmm. Looks like an issue with pip and that particular package. Quick Google search turned up this:

    https://stackoverflow.com/questions/18884761/cant-install-mongoctl

    Since you have argparse installed, have you tried using csvkit?

  3. Ojas says:
    pip install --allow-all-external csvkit

    has resolved the issue

  4. Jaminyah says:

    There is no C:\Python27\Scripts\; folder associated with Python 2.7 installation. There is however C:\Python27\Tools\Scripts\;

    Can you comment on this issue?

  5. Anthony says:

    If you run through all the steps in this tutorial, you’ll have a C:\Python27\Scripts folder.

  6. Aman says:

    i installed python and after that i open light table i get

    Failed to save: default.clj

    Error: EPERM, operation not permitted ‘C:\Users\Amanpreet\AppData\Local\LightTable\ltcache\default.clj’

    please help, am new to this so explain in lehman terms

  7. Dinesh Murani says:

    Really nice Anthony. Sharing is caring. Keep sharing as much as possible.

    Thank you.

  8. Ian says:

    Anthony – as stated by Jaminyah when 2.7.6 is installed as per your article there is no C:\Python27\Scripts\ directory created. Is it Ok to just create this directory or should I modify the path to point to C:\Python27\Tools\Scripts\ ? I had previously installed 3.4 which did have a C:\Python34\Scripts\ directory but I just couldn’t get it to work so uninstalled and installed 2.7.6 which activated when I ran cmd then C:> python

    Now I’m not sure where to put my gimpshop python scripts as they don’t seem to be being found in the gimpshop\lib\gimp\2.0\plug-ins directory, despite that also being in the user path…

  9. Anthony says:

    Ian,

    Not sure why you’re not getting a C:\Python27\Scripts\ directory, as it’s always added whenever I do an install on Win 7 or Win 8. You can go ahead and add it manually.

    Many other install docs reference that directory as well. For example: http://docs.python-guide.org/en/latest/starting/install/win/

  10. Mike says:

    Looks like I had to reboot Windows 8.1 after changing the path. Lame.

  11. Anthony says:

    Mike,

    Usually just closing and re-opening the command prompt does the trick.

  12. Ismail says:

    Hello Anthony,

    Being a newbie in Python, I installed it following the above instructions, yet I am facing the same ambiguity as Jaminyah: I don’t have a Scripts folder in Python27, but I don’t find it in the Tools folder. Should I add C:/Python27/Tools/Scripts or is something wrong with my installation ?

    Thanks.

  13. Ismail says:

    Never mind, it works now. Thanks

  14. Joey says:

    Great instructions, Anthony. Python installed from scratch with all the things in under an hour on Windows 8.1.

  15. Anthony says:

    Glad it helped, Joey!

  16. Abhishek says:

    Fantastic tut Anthony !! That covered everything one needed to install python ;)

Leave a Reply