0

enter image description hereI need to install PIP for Python 2.7.3.

I have run the get-pip.py file in Python IDLE shell. However, it raises the following exception:

ValueError: Unable to configure handler 'console': closed

Here is the screenshot:

How can fix this error?

Here is the error faced when trying to execute python get-pip.py in the command prompt:

inspite of correct path no execution result

summer93
  • 11
  • 1
  • 9

1 Answers1

1

You need to run Python as an elevated process in order to have write access to the program files directory where pip will get installed. The simplest and best way to do that is to launch an elevated command prompt cmd.exe.

In Windows 7 and later, you can best do that by opening the start menu using the Windows key, and then typing cmd. This should give you the command prompt as the first result. Right click on it, and choose “Run as administrator”. After accepting the UAC dialogue, this will then start an elevated command prompt with proper write access.

The run the script, then use the following command as explained in the pip installation manual:

python get-pip.py

Of course you need to adjust the path to the get-pip.py file. For example if the file is in your downloads folder, you can write the following:

python C:\Users\<username>\Downloads\get-pip.py

This should the properly install pip for the current Python version.

Note that in order to use pip later, you also need to run it always from an elevated command prompt, as every PyPI module is also installed into the Python directory in your program files (unless you’re using virtual environments of course). So you then need to run e.g. pip install beautifulsoup4. If pip.exe is not in your path, which likely be the case, you can also run pip using the Python executable like this: python -m pip install beautifulsoup4.

poke
  • 307,619
  • 61
  • 472
  • 533
  • Thank you for the detailed reply. i have a few problem areas though . when i run python get-pip.py in the command prompt , i get error: 'python ' is not an exteranl or internal command. please help – summer93 Jan 05 '16 at 11:10
  • Then Python also isn’t in your PATH. You can try using `py` instead of `python` (i.e. `py get-pip.py`) if you have the Python launcher on your system; if that also doesn’t work, you need to specify the full path to the Python executable, e.g. something like `C:\Program Files\Python27\python.exe get-pip.py` or whatever the path to your Python installation is (you will have to figure that out yourself). – poke Jan 05 '16 at 11:17
  • hi. i added a third image to demonstrate my issue. i specified the right path in the command prompt to run get-pip.py.this time no error message(thank u @poke ), but no results are displayed either. – summer93 Jan 05 '16 at 12:06
  • You need to run `python.exe` not `pythonw.exe` (note the `w`). – poke Jan 05 '16 at 12:09
  • i got the path address from IDLE using commands print sys.executable. is that not right??. – summer93 Jan 05 '16 at 12:10
  • IDLE runs `pythonw`, yes. But you still need to use `python.exe` here. – poke Jan 05 '16 at 12:59
  • If you find yourself frequently needing an elevated command prompt, you can avoid the routine of "run as administrator" and agreeing to the consent dialog by creating a task that runs elevated, e.g. `schtasks /create /tn ecmd /tr "cmd.exe /t:0E /k 'cd %USERPROFILE% & title Command Prompt'" /ru %USERNAME% /rp /it /rl highest /sc once /st 00:00 /sd 01/01/1900`. Then run it using `schtasks /run /i /tn ecmd`. You can set this command in an ecmd.lnk shortcut, or ecmd.bat. For the former, add .LNK to `PATHEXT` to avoid having to type the extension. Put the shortcut/batch in a `PATH` directory. – Eryk Sun Jan 05 '16 at 16:16