'Getting error Bad File Descriptor while installing pip

whenever i try to install pip i always get this error. pls help . i dont know how to fix this i tried doing it using the default python executable using the modify method and also tried the get-pip.py file method nothing works. i have checked my path variables too so the scripts folder is there but pip is not installed.

    PS C:\Users\ismai\Desktop\programs\PYTHON> python get-pip.py
Traceback (most recent call last):
  File "C:\Users\ismai\Desktop\programs\PYTHON\get-pip.py", line 23704, in <module>
    main()
  File "C:\Users\ismai\Desktop\programs\PYTHON\get-pip.py", line 198, in main
    bootstrap(tmpdir=tmpdir)
  File "C:\Users\ismai\Desktop\programs\PYTHON\get-pip.py", line 83, in bootstrap
    from pip._internal.commands.install import InstallCommand
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\ismai\AppData\Local\Temp\tmpz82tcza4\pip.zip\pip\_internal\commands\install.py", line 17, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\ismai\AppData\Local\Temp\tmpz82tcza4\pip.zip\pip\_internal\cli\req_command.py", line 16, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\ismai\AppData\Local\Temp\tmpz82tcza4\pip.zip\pip\_internal\index\collector.py", line 14, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\ismai\AppData\Local\Temp\tmpz82tcza4\pip.zip\pip\_vendor\requests\__init__.py", line 125, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\ismai\AppData\Local\Temp\tmpz82tcza4\pip.zip\pip\_vendor\requests\utils.py", line 27, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\ismai\AppData\Local\Temp\tmpz82tcza4\pip.zip\pip\_vendor\requests\_internal_utils.py", line 11, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\ismai\AppData\Local\Temp\tmpz82tcza4\pip.zip\pip\_vendor\requests\compat.py", line 65, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 786, in exec_module
  File "<frozen importlib._bootstrap_external>", line 922, in get_code
  File "<frozen importlib._bootstrap_external>", line 980, in get_data
OSError: [Errno 9] Bad file descriptor


Solution 1:[1]

Ok guys i tried unistalling this new version(3.9) and then installed an old version(3.7) and then ran the command python get-pip.py and magically it worked. if anyone in future wants to fix this issue then try this. i also read the python documenttion and apparantly they have a command if pip isnt installed on your version of python that is python -m ensurepip so you can try that too.

Solution 2:[2]

I actually had a similar problem and tried every possible solution, the only one which worked with me is to uninstall python and reinstall it in different partition other than the C , it will work !

Solution 3:[3]

Go to the folder in which you Python installer is there and click on it. It will open the installer and show "modify setup":

Screenshot of Python install wizard on top of PyCharm

Solution 4:[4]

Uninstall python and then download it from https://www.python.org/downloads/ reinstall it and make sure to check the box that adds pip to PATH.

Solution 5:[5]

And then click on "Uninstall". After uninstall done click on close and again go to your installer and click on it and after that it will show like this.

Solution 6:[6]

After check Add python to PATH and click on "customize installation". Check everything in advanced option and click install.

Done!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mysteri0us
Solution 2 Youssif Sayd
Solution 3 Chris
Solution 4 BeeFriedman
Solution 5 adps
Solution 6 adps