2

Everytime I try to use pip to do something

pip install <package>

I get an error

OSError: [Errno 9] Bad file descriptor

I tried installing and reinstalling anaconda. I'm currently trying to create a virtualenv from pycharm and can't seem to do so because of this error. I need some new packages for a new project and need a way around this.

If anyone faced similar circumstances or want more debug information regarding my system please leave a comment down below, I'd be happy to help!

Here's a full stack trace for the error I'm getting while using pip:


Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.3\helpers\packaging_tool.py", line 192, in main
    retcode = do_install(pkgs)
  File "C:\Program Files\JetBrains\PyCharm 2017.3\helpers\packaging_tool.py", line 106, in do_install
    import pip
  File "D:\venv1\lib\site-packages\pip-9.0.1-py3.6.egg\pip\__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "D:\venv1\lib\site-packages\pip-9.0.1-py3.6.egg\pip\_vendor\requests\__init__.py", line 65, in <module>
    from . import utils
  File "D:\venv1\lib\site-packages\pip-9.0.1-py3.6.egg\pip\_vendor\requests\utils.py", line 23, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "D:\venv1\lib\site-packages\pip-9.0.1-py3.6.egg\pip\_vendor\requests\compat.py", line 60, in <module>
    from http.cookies import Morsel
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 780, in get_code
  File "<frozen importlib._bootstrap_external>", line 833, in get_data
OSError: [Errno 9] Bad file descriptor

Can this be an issue with regarding python version? Currently using python 3.6.3 on Windows 10 and PyCharm 2017.3

3
  • How did you create the venv? Commented Jul 19, 2019 at 8:23
  • A lot of folks have been reporting this error recently. Did you ever get it resolved? Was this a normal computer with C and D drives on normal physical hard disks ? Or was something virtualized or externally mounted? Check if the file at {PythonInstallDir}\Lib\http\cookies.py is available and accessible.
    – Amit Naidu
    Commented Oct 14, 2020 at 1:19
  • I did get it resolved. As far as I remember completely purged the current installation and switched to a newer version. Yes, it had drives on physical hard disks. I'm sorry I can't verify the file as I never faced that issue again
    – tahmeed156
    Commented Oct 14, 2020 at 3:44

0

You must log in to answer this question.

Browse other questions tagged .