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.

35 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 😉

  17. Anirudhha says:

    my showing import error :no module named ‘cryto ‘ after all the steps above given by you .v

  18. Nevin says:

    Thanks for the help! It’d been awhile since I’d set up a system, especially a PC!

  19. Ale says:

    Hi thanks for the great guides!

    I have this:

      Running setup.py install for sqlalchemy
        building 'sqlalchemy.cprocessors' extension
        ***************************************************************************
        Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms
    /vcpython27
        WARNING: The C extension could not be compiled, speedups are not enabled.
        Failure information, if any, is above.
        Retrying the build without the C extension now.
        ***************************************************************************
    
        warning: no files found matching '*.jpg' under directory 'doc'
        warning: no files found matching 'Makefile' under directory 'doc'
        warning: no files found matching 'distribute_setup.py'
        warning: no files found matching 'sa2to3.py'
        warning: no files found matching 'ez_setup.py'
        no previously-included directories found matching 'doc\build\output'
        ***************************************************************************
        WARNING: The C extension could not be compiled, speedups are not enabled.
        Plain-Python build succeeded.
        ***************************************************************************
    

    what should I do?

    Thanks

  20. Anthony says:

    Ale,

    Here are a couple possible fixes for the “unable to find vcvarsall.bat” problem:

    1) The easiest thing to do is download precompiled Windows binaries here:
    http://www.lfd.uci.edu/~gohlke/pythonlibs/

    2) Other options:
    http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat
    http://stackoverflow.com/questions/19830942/pip-install-gives-error-unable-to-find-vcvarsall-bat

  21. Manbir says:

    Thanks Anthony. I almost gave up python because I could not install Beautiful soup. I am glad to find this great article. It helped me in getting started.
    Thank you

  22. Benny says:

    I didn’t read the other comments so I don’t know if someone already mentioned that. You can activate the Option to automatically put Python to the system PATH variable on the very bottom of the list of things to install, so you don’t have to put this manually after installing. Worked fine for me. If there’s no one complaining to have problems after that you may add that to the Tutorial 😉

  23. Damian says:

    Thank you, Antony! Helped alot. Could you please tell the best way to install Django under Windows 8?

  24. Anthony says:

    Damian,

    Running this will install Django:

    pip install django

    For local development, you can use Django’s built-in development server. Check their tutorials.

  25. Devin Cutler says:

    Dear Anthony:

    I am not a huge techie.

    My 13 year old son just got a Windows 8.1 laptop and had been happily learning python on his old Windows 7 laptop. He wanted to continue to program and run his game scripts on his new machine. I followed the above advice, specifically installing 32 bit Python 2.7.9 and setting the PATH variable as you indicated.

    When I go to the command line and type “python” I get the Python interpreter. All good and well so far.

    But then I try to run his script from the command line and nothing happens. It just returns the command prompt again.

    His scripts are in the C:\Python27\Scripts folder.

    I have tried running them by typing the script name plus the .py extension (which just returns the command prompt)or by typing “python scriptname.py” (which results in a “can’t open file [Errno2}” message) but nothing works. And I have tried these from both the command line:

    C:\Users\username

    and

    C:\Python27\Scripts

    Nothing works. Am I doing something wrong?

    Can you offer any advice to this newbie?

    Thanks,

    Devin

  26. Newton says:

    Thank you for the hand-holding. While I am sad to know that I needed it, I did need it to get through so I am grateful your tutorial was here. Followed the step-by-step and finally got everything in correctly. The only thing in the whole tutorial that caused any confusion for me, was that there is a SYSTEM PATH variable already, in my computer, but not a USER one, so I was concerned that I was adding to the wrong PATH, though it seems that the installs have gone beautifully so I worried for nothing.

    Thank you!

  27. […] I didn’t think about using W8.1 being an issue, though it has been. Thankfully, Anthony DeBarros’s super helpful tutorial broke it down a lot for me. Had I just searched for 8.1 specific set up […]

  28. Anthony says:

    Devin,

    First, I would suggest moving your son’s scripts to their own folder, perhaps c:\PythonScripts. Keep them separate from system Python things.

    Then cd into that folder and run:

    python script-name.py

    (Replace script-name.py with the name of his script.)

  29. anukriti says:

    Thanks alot! It was really helpful.
    I tried to install Twisted by using: pip install twisted. It got successfully installed, but gave some warnings.

    C:\>pip install twisted
    Downloading/unpacking twisted
    Downloading/unpacking zope.interface>=3.6.0 (from twisted)
      Running setup.py (path:c:\users\anukriti\appdata\local\temp\pip_build_anukriti
    \zope.interface\setup.py) egg_info for package zope.interface
    
        warning: no previously-included files matching '*.dll' found anywhere in dis
    tribution
        warning: no previously-included files matching '*.pyc' found anywhere in dis
    tribution
        warning: no previously-included files matching '*.pyo' found anywhere in dis
    tribution
        warning: no previously-included files matching '*.so' found anywhere in dist
    ribution
    Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\pytho
    n27\lib\site-packages (from zope.interface>=3.6.0->twisted)
    Installing collected packages: twisted, zope.interface
      Running setup.py install for zope.interface
    
        warning: no previously-included files matching '*.dll' found anywhere in dis
    tribution
        warning: no previously-included files matching '*.pyc' found anywhere in dis
    tribution
        warning: no previously-included files matching '*.pyo' found anywhere in dis
    tribution
        warning: no previously-included files matching '*.so' found anywhere in dist
    ribution
        building 'zope.interface._zope_interface_coptimizations' extension
        ****************************************************************************
    ****
        WARNING:
    
                An optional code optimization (C extension) could not be compiled.
    
                Optimizations for this package will not be available!
        ()
        Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it
    from http://aka.ms/vcpython27
        ****************************************************************************
    ****
        Skipping installation of C:\Python27\Lib\site-packages\zope\__init__.py (nam
    espace package)
        Installing C:\Python27\Lib\site-packages\zope.interface-4.1.2-py2.7-nspkg.pt
    h
    Successfully installed twisted zope.interface
    Cleaning up... 

    what about these warnings?

  30. Anthony says:

    Anukriti,

    Not 100% sure but I believe it’s looking for a compiler and not finding one. As you say, though, it probably installed just fine. Other experts who hang around here might know better.

    Most Python packages install OK with pip on Windows, but any time I think I’m in trouble I look for a Windows binary and install that using pip. You can find a bunch at this incredibly helpful page:

    http://www.lfd.uci.edu/~gohlke/pythonlibs/

  31. Very helpful article! Thanks :)

  32. Issam says:

    Hello Antony,
    i am new for python,i am using a laptop with windows 8.1,i followed the instructions upwards,i installed python2.7 i changed the path but its still showing the old path when opening the command prompt,and when trying to run the hello.py file from the google exercises its giving “Access is denied” and after loading the Python interpreter i run the same file its giving a syntax error.finally when i press Control-Z its not exiting to the interpreter and get back to a C: prompt,its happening when i press ctrl-x.Thamks in advanced

  33. Anthony says:

    Issam,

    The PATH you enter above is different than the path if your command prompt. If you can type python at the command line and get the interpreter, then you’re up and running.

  34. ruedaCid says:

    Great tutorial, thanks

  35. AC says:

    Quite useful and easy to follow. Thanks Anthony!

Leave a Reply