25

So I'm trying python 2.7 on my Windows. It is running Windows 8. I cannot add it to my path. I've done the usual: using the advanced system settings, environment variables, adding C:\Python27 in system variables.

However, when I type Python in command prompt it says 'python is not recognized ..'

Alex
  • 97
  • 3
  • 8
lars
  • 1,976
  • 5
  • 33
  • 47
  • 4
    If the Python installer changes the PATH variable, it will not be seen in the current cmd.exe shell. A new cmd.exe shell must be started. After starting a new cmd.exe shell, use the following command to see if Python was added to the path. ECHO %PATH% If not, use the Windows GUI through Control Panel, then start a new cmd.exe shell. – lit May 05 '14 at 15:05

9 Answers9

64

I think that the essence of this question is how to install Python and be able to use it from the command line. The steps below show how to get all that working. Check that you didn't miss anything:

  1. From https://www.python.org/download/releases/2.7.6 download appropriate Python 2.7.6 Windows Installer. (If that link doesn't work, check https://www.python.org/downloads/)
  2. Run the file
  3. Select install for all users or install just for me, click Next
  4. You'll see it installs under the C:\Python27 folder, click Next
  5. Click Next again for the 'Customize Python' step
  6. Click Finish
  7. Open Control Panel, then System
  8. Click 'Advanced system settings' on the left
  9. Click the 'Environment Variables' button
  10. Under 'System variables' click the variable called 'Path' then the 'Edit...' button. (This will set it for all users, you could instead choose to edit the User variables to just set python as a command prompt command for the current user)
  11. Without deleting any other text, add C:\Python27; (include the semi-colon) to the beginning of the 'Variable value' and click OK.
  12. Click OK on the 'Environment Variables' window.

Open a new command prompt window type python, you will have python running in the command prompt. Note: command prompt windows open prior to setting the Environment Variable will not have the python command available.

kchetan
  • 4,987
  • 2
  • 18
  • 17
bnp887
  • 5,128
  • 2
  • 26
  • 30
  • 1
    Step 1 link is broken. Currently working link : https://www.python.org/download/releases/2.7.6 – Akhil Apr 01 '14 at 18:35
  • 3
    Note that you can also add a `Path` environment variable to the `User variables for XXXXX` section. Then it won't pollute the path for every user of the computer. Also, there is no need to reboot. You can close the command prompt window and re-open a new one which will use the new `Path`. – dbasch Jul 11 '14 at 05:50
  • 2
    Reboot is not needed. Just restart the tool needing Python – frlan Sep 03 '14 at 13:53
  • 1
    Step 11. in Windows 10, ignore the semi-colon. add only `C:\Python27` – A.A Aug 28 '19 at 20:55
7

Easiest way is to open CMD or powershell as administrator and type

set PATH=%PATH%;C:\Python27
5

System variables usually require a restart to become effective. Does it still not work after a restart?

bnp887
  • 5,128
  • 2
  • 26
  • 30
2

Make sure you don't put a space between the semi-colon and the new folder location that you are adding to the path.

For example it should look like...

{last path entry};C:\Python27;C:\Python27\Scripts;

...not...

{last path entry}; C:\Python27; C:\Python27\Scripts;

Will
  • 773
  • 1
  • 7
  • 24
2

How to install Python / Pip on Windows Steps

  1. Visit the official Python download page and grab the Windows installer for the latest version of Python 3. python.org/downloads/
  2. Run the installer. Be sure to check the option to add Python to your PATH while installing.

  3. Open PowerShell as admin by right clicking on the PowerShell icon and selecting ‘Run as Admin’

  4. To solve permission issues, run the following command:

Set-ExecutionPolicy Unrestricted

  1. Next, set the system’s PATH variable to include directories that include Python components and packages we’ll add later. To do this: C:\Python35-32;C:\Python35-32\Lib\site-packages\;C:\Python35-32\Scripts\

  2. download the bootstrap scripts for easy_install and pip from https://bootstrap.pypa.io/ ez_setup.py get-pip.py

  3. Save both the files in Python Installed folder Go to Python folder and run following: Python ez_setup.py Python get-pip.py

  4. To create a Virtual Environment, use the following commands:

cd c:\python pip install virtualenv virtualenv test .\test\Scripts\activate.ps1 pip install IPython ipython3 Now You can install any Python package with pip

That’s it !! happy coding Visit This link for Easy steps of Installation python and pip in windows http://rajendralora.com/?p=183

thor
  • 21,418
  • 31
  • 87
  • 173
Rajendra
  • 21
  • 1
2

Type this in Windows PowerShell or CMD:

"[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")"

After running the command, please restart PowerShell or CMD. If it still doesn't work, restart your PC.

dirtydanee
  • 6,081
  • 2
  • 27
  • 43
2

there is a simple procedure to do it go to controlpanel->system and security ->system->advanced system settings->advanced->environment variables then add new path enter this in your variable path and values

enter image description here

toha
  • 5,095
  • 4
  • 40
  • 52
Snivio
  • 1,741
  • 1
  • 17
  • 25
1

i'm using python 2.7 in win 8 too but no problem with that. maybe you need to reastart your computer like wclear said, or you can run python command line program that included in python installation folder, i think below IDLE program. hope it help.

hendrakmg
  • 37
  • 7
1

GUI Option:

  1. Open System Properties

    a. Type it in the Start Menu

    b. Use the keyboard shortcut Win+Pause)

    c. From Windows Explorer address bar go to

    %windir%\System32\SystemPropertiesProtection.exe

    d. Write SystemPropertiesProtection in run window and press Enter

  2. Switch to the Advanced tab

  3. Click Environment Variables
  4. Select PATH in the System variables section
  5. Click Edit
  6. Add python's path to the end of the list (the paths are separated by semicolons).

For example:

C:\Windows;C:\Windows\System32;C:\Python27

Command Line Option:

  1. Run Command Prompt as administrator
  2. Check existing paths under PATH variable (the paths are separated by semicolons). If your python folder already listed then no need to add again. Default python folder is C:\Python27

    C:\Windows\system32>path or C:\Windows\system32>echo %PATH%

  3. Append python path using setx command. The /M option sets the variable at SYSTEM scope.

The default behavior is to set it for the USER.

C:\Windows\system32>setx /M PATH "%PATH%;C:\Python27"
Rafayet Ullah
  • 1,108
  • 4
  • 14
  • 27