Setting up Python in Windows 8.1
Note: Also see my guide to Python setup for Windows 10!
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
- 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.
- 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\;
- 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
- 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).
- 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.
- 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
- 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.
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.
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?
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?
has resolved the issue
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?
If you run through all the steps in this tutorial, you’ll have a C:\Python27\Scripts folder.
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
Really nice Anthony. Sharing is caring. Keep sharing as much as possible.
Thank you.
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…
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/
Looks like I had to reboot Windows 8.1 after changing the path. Lame.
Mike,
Usually just closing and re-opening the command prompt does the trick.
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.
Never mind, it works now. Thanks
Great instructions, Anthony. Python installed from scratch with all the things in under an hour on Windows 8.1.
Glad it helped, Joey!
Fantastic tut Anthony !! That covered everything one needed to install python 😉
my showing import error :no module named ‘cryto ‘ after all the steps above given by you .v
Thanks for the help! It’d been awhile since I’d set up a system, especially a PC!
Hi thanks for the great guides!
I have this:
what should I do?
Thanks
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
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
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 😉
Thank you, Antony! Helped alot. Could you please tell the best way to install Django under Windows 8?
Damian,
Running this will install Django:
For local development, you can use Django’s built-in development server. Check their tutorials.
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
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!
[…] 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 […]
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:
(Replace script-name.py with the name of his script.)
Thanks alot! It was really helpful.
I tried to install Twisted by using: pip install twisted. It got successfully installed, but gave some warnings.
what about these warnings?
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/
Very helpful article! Thanks 🙂
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
Issam,
The PATH you enter above is different than the path of your command prompt. If you can type
python
at the command line and get the interpreter, then you’re up and running.Great tutorial, thanks
Quite useful and easy to follow. Thanks Anthony!
thank you so much for the step by step! very helpful 🙂
Glad you all find this useful!
Just starting in python on my own. Was totally confused about setuptools, pip, requests, etc until I found your site. Most “help” out there is only intelligible if you already know what they are trying to tell. Yours is one of the few that explains concisely and thoroughly what the lost (me) needs to know. It guided me through exactly what I needed to know and how to do it. In no time I had all the components I need.
Thank you. Thank you. Thank you.
Hi,
Thanks for the handy tutorial. I was able to setup Python just in 30 mins.
I am trying to follow Google Python class, my Python 2.7 installation seems to work but I cannot run any of their exercises (e.g script hello.py)..why
Thanks a ton, i got python up & running in less than 10 minutes. Thanks for sharing.
Thank you very much. You helped me to solve a problem which has already consumed tens of hours to solve. Thanks a lot . Keep the good work
Sir Anthony,
Thank you very much. I am just started with Python development. This tutorial helps me to python installation.
Hello Sir
Can you please help me fix the problem which I’m getting while installing Python on my Windows 8.1
It shows the following:
Setup failed
One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the log file. 0x80240017- Unspecified error
If you help me fix this issue , it would be very thankful of you.
Hi, Debolina,
Unfortunately, there isn’t enough information in your comment for me to help diagnose the issue. Perhaps another reader will be able to help.
[…] Instala Python 2.7 si es que aún no lo tienes, y asegúrate de añadir su la dirección de instalación a tu PATH. […]
your advice was great but i am coding in python 3xx not 2.7 which is obsolate thanks nay way im going continues reseaching until i find solutions.
nice version
You Sir are a life saver. Been pulling my hair out trying to open a plug-in I bought and until I found you I was dead in my tracks. Followed your instructions and got the job done. Thanks again.