Setting up Python in Windows 10

Installing Python under Windows 10 follows a similar script to installs under older versions of the operating system. In fact, this post follows closely on my previous entries about installing Python under Windows 7 and under Windows 8.1. The biggest difference here is that we’re going to work with Python 3 instead of Python 2.

Ready? Here’s your quick guide:

Set up Python on Windows 10

1. Visit the official Python download page and grab the Windows installer for the latest version of Python 3. A couple of notes:

  • Python is currently available in two versions — Python 2 and Python 3. For beginners, that can be confusing. In short, Python 3 is where the language is going; Python 2 has a large base of existing users but isn’t developing beyond bug fixes. Read this for more.
  • By default, the installer provides the 32-bit version. There’s also a 64-bit version available. I’ve generally stuck with 32-bit for compatibility issues with some older packages, but installing is so easy you can experiment with either.

2. Run the installer. You’ll have two options — choose “Customize Installation.”

3. On the next screen, check all boxes under “Optional Features.” Click next.

4. Next, under “Advanced Options,” set the location where you want to install Python. For ease, I use:

C:\Python35-32

That refers to an installation of 32-bit Python 3.5.

5. 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 (easy way: right click the Start Menu icon and select Control Panel).
  • In the Control Panel, search for Environment; click Edit the System Environment Variables. Then click the Environment Variables button.
  • In the User Variables section, we will need to either edit an existing PATH variable or create one. If you are creating one, make PATH the variable name and add the following directories to the variable values section as shown, separated by a semicolon. If you’re editing an existing PATH, the values are presented on separate lines in the edit dialog. Click New and add one directory per line.
C:\Python35-32;C:\Python35-32\Lib\site-packages\;C:\Python35-32\Scripts\

6. Now, you can open a command prompt (Start Menu | Windows System | Command Prompt) and type:

python

That will load the Python interpreter:

Python 3.5.1  (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win 32
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.

Type exit() and hit Return to exit the interpreter and get back to a C: prompt.

Optional: Set up useful Python packages

Python 3 comes with the package installer pip already in place, which makes it super easy to add useful packages to your Python installation. The syntax is this (replace some_package with a package name you want to install):

pip install some_package

1. Let’s add a couple of must-have utilities for web scraping: Requests and BeautifulSoup. You can use pip to install them all with one command:

pip install beautifulsoup4 requests

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

pip install csvkit

 

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

49 responses to “Setting up Python in Windows 10”

  1. Justin says:

    During the install there is a checkbox that says “Add Python 3.5 to PATH.” Does this work rather than manually setting it in step 3 above?

  2. Justin says:

    To follow up, checking the box during the install seems to work, at least accessing Python through IDLE (I haven’t tried anything else).

    Thanks for the helpful instructions!

  3. Carlos says:

    Thanks man, I am new to Windows 10 and this was really helpful!

  4. waya says:

    Hallo, this has been very helpfull man. However, I got a problem with pip install some_package command…an error that says could not find a version that satisfies the requirement…any help please

  5. Anthony says:

    Waya,

    Replace some_package with an actual package name, such as csvkit.

  6. Philbert says:

    For me, the default install did not install it to C:\Python35, but to some deep AppData folder (C:\Users\Philbert\AppData\Local\Programs\Python to be exact)

    This annoyed me, so I uninstalled it and went for the custom install. There you get the choice to set the install folder (so I set it to C:\Python35) and as mentioned above, to have the installer create the environment variables (path) for you.

  7. Anthony says:

    Philbert,

    Thanks for the heads-up on that. Looks like Python 3.5’s installer now offers that option, and I’ve made a change to the instructions.

  8. […] 3 donde se haya instalado. Para el caso de Windows 10 los pasos varían un poco, sin embargo este enlace muestra todos los pasos para esa […]

  9. Ann says:

    Thank you for sharing! I’m new to python and window 10. I found the following steps confusing:

    In the User Variables section, edit the PATH statement to add this (if there is no PATH variable, click NEW to create one):
    C:\Python35-32
    C:\Python35-32\Lib\site-packages\
    C:\Python34\Scripts\

    Do I suppose to create three user variables with different names? I try to create a variable named ‘PATH’, however, when I move to the next directory with the same name, it just clear the previous information. So I’m really confused about what I need to do. Could you provide a step by step instruction for this part? Thanks!

  10. Anthony says:

    Ann,

    I clarified the instructions in the post. Windows 10 presents one dialog if you’re creating a new PATH, and a different dialog if you’re editing a PATH. (At least that’s what I see on my system.)

  11. Philbert says:

    Awesome Anthony. This is the best how to on installing Python that I have seen.

  12. Vera says:

    thank you for that great instructions!!!

  13. Sam says:

    Anthony,

    So in the event that I added the PATH variable, and it still doesn’t recognize it, what would you suggest?

    Python installed two directories: Python 3.5 and Python35-32, both in Program Files (x86). First I tried to have the installer add the path variables, but for some reason, that didn’t work. I then tried manually adding paths for 35-32, 3.5, and both at the same time, as the following line shows, but none of those worked. It still does not recognize “python” as an internal or external command.

    “C:\Program Files (x86)\Python35-32;C:\Program Files (x86)\Python35-32\Lib\site-packages;C:\Program Files (x86)\Python35-32\Scripts;C:\Program Files (x86)\Python 3.5;C:\Program Files (x86)\Python 3.5\Lib\site-packages;C:\Program Files (x86)\Python 3.5\Scripts”

    Thanks!
    – Sam

  14. Anthony says:

    Sam,

    You definitely don’t want to have both installs in your PATH. Choose one and use that. Also, make sure you start a new command prompt after you make the change. If you have a command prompt active while you make the change, it won’t be recognized in the active prompt.

  15. Karl says:

    Was a little miffed it wasn’t working for me until I read your comment to Sam and remembered I had to reset my cmd. Works like a charm. Running my OS from an SSD and python from my HDD.

  16. Your instructions do not actually install PIP. The only thing they do is install the Python binary. When I try to run `pip`, I get an error “pip’ is not recognized as an internal or external command”.

  17. Anthony says:

    Igor,

    This tutorial focuses on Python 3, which includes pip: https://docs.python.org/3.5/installing/index.html

    Did you install Python 3.5?

  18. Yes, but pip wasn’t part of it. I had to install it separately.

  19. Prajwal says:

    I changed the PATH variables and everything but yet when I type ‘python’ on the cmd it display ‘no such command found’. I am using windows 10

  20. Anthony says:

    Prajwal,

    Did you quit your command terminal and restart it?

  21. Cluley says:

    Hi, I just added 3.5. I selected the add to path option in the installation tool. It only added C:\Python35-32 and C:\Python34\Scripts\. So I have added C:\Python35-32\Lib\site-packages\ manually. Hopefully this will work.

  22. Anthony says:

    Cluley,

    It would be odd to have both C:\Python35-32 and C:\Python34\ paths — that reflects two different versions. Edit to standardize on one or the other.

    Also, always quit and restart the command terminal to see changes take effect.

  23. Eshwar says:

    Thanks for this man.. However, I got a problem with pip install some_package command…an error that says could not find a version that satisfies the requirement.. I replaced some_packages to csvkit. Then also the same error continies. Can you please help me

  24. Anthony says:

    Eshwar,

    What happens when you simply type pip on the command line? If that works, what happens when you type pip search csvkit?

  25. Alex says:

    I have been trying to figure this out for a few days and that advanced options part really helped me! Thank you so much!!!!!

  26. Jack says:

    Um, I still can’t do this I set up the path to my documents and it didn’t work for setting path

  27. chad says:

    honestly….I have posted on stackO, etc and you my friend have been my salvation thank you so much for this.

  28. Mike Garrant says:

    After multiple install attempts I getting following when attempting to start python from command prompt:

    C:\Windows\System32>python
    Fatal Python error: Py_Initialize: unable to load the file system codec
    Traceback (most recent call last):
      File "c:\Python35-32\lib\encodings\__init__.py". line 31, in 
    zipimport.ZipImportError: can't find module 'codecs'
    
    C:\Windows\System>
  29. Anthony says:

    Mike,

    Not quite sure what the issue is, but I suggest Googling the error message and trying a few things with your Python path. Start with: http://stackoverflow.com/questions/18946286/python3-installed-successfully-but-cannot-be-opened-in-terminal

  30. Edwin F, Meyer says:

    I can get to the Python shell by typing “python” at the C: prompt OK, but how do I get to the page where indents are automatic, and different colors appear for different types of words, etc.? “IDLE” is not recognized.

  31. Elise Hang says:

    I followed all the steps mentioned for installation of Python 3.5 and still pip doesn’t work for me. When i type pip in the terminal, it displays a message saying – name not defined and i have checked the other link as well. It’s simply not working.

  32. Anthony says:

    Did you close and re-open your terminal window? Also, confirm that your PATH settings are correct.

  33. Pranav says:

    thanks, it works fine.

  34. Matt says:

    I tried to pip install mechanize, beautiful soup, and requests, but I keep getting an invalid syntax message.

  35. Anthony says:

    Can you post the exact message here? Also, did you restart your terminal window?

  36. Matt says:

    I started it back up just now and typed in “pip install mechanize beautifulsoup4 requests” and it still gave me the message “syntaxerror: invalid syntax”.

  37. Anthony says:

    Are you running the command at your C: prompt or within the Python interpreter? pip should be run from your C: prompt (aka command line).

  38. Matt says:

    I’m not sure. Can you tell me how to get to c: prompt so that I’ll know for sure?

  39. Anthony says:

    Matt,

    It’s under Start Menu | Windows System | Command Prompt.

  40. Matt says:

    I couldn’t find that in my start menu, so, I searched and it came up. It all worked there. Thank you very much for your help.

  41. Jason says:

    Just wanted to say thanks for writing this tutorial. Brand new to python and after 2.5 hours of searching it was your tutorial that finally allowed me to install BeautifulSoup successfully.

  42. Anthony says:

    Jason: Glad to know this is helping people!

  43. Kavish says:

    Great tutorial Anthony!!
    Worked for me Thanks..

  44. oli says:

    Thank you.Worked like a charm.

  45. I have two different classes I’m taking and need both python 2.7 and 3.5. I’m not clear on how to install both and clean up the PATH to work correctly in Windows 10?

    I’m imagining installing to C:\Python27 and C:\Python35, what would I do to get the proper installation and PATH.

    From what I gather I should be able to run one or the other by adjusting something there so that from my CMD propmpt I’ll have something like C:\Users\chrisgrazioli>python27 to run 2.7
    and
    C:\Users\chrisgrazioli>python to run 3.5

  46. Gene says:

    Everything seems to have installed properly based on your directions. Thank you!

  47. Anthony says:

    Christopher,

    The easiest option is to install both versions and change your path statements when you need to use one version or the other.

    A second option, which requires more initial setup but makes life far easier, is to get familiar with setting up virtual environments. Check out virtualenv (https://virtualenv.pypa.io/en/stable/) and virtualenvwrapper (https://pypi.python.org/pypi/virtualenvwrapper/).

  48. Christopher Grazioli says:

    So I went ahead and downloaded the .msi for python 2.7 and 3.5. I ran 2.7 first and checked to add it to the path, then I installed 3.5 and checked to add that to the path. After install I ran a command prompt for “python” and it only runs 3.5. So I went into the C:\Python27 folder where I installed it and renamed the executable file: python.exe to python27. I thought I was home free when I typed “python27” in the command prompt and Python 2.7 fired right up, but I can’t get “pip” or “pip install [any package]” to run. I get, {Fatal error in launcher:unable to create process using ‘”‘} Anyone have any ideas on squaring this away

Leave a Reply

Your email address will not be published. Required fields are marked *