cmd에서 pip를 사용하여 pip를 업그레이드하거나 새 패키지를 설치하려고 하면 다음 오류가 표시됩니다. Python을 제거하고 다시 설치했지만 문제가 여전히 존재합니다. 내 현재 Python 버전은 3.7.3이며 Windows 10 플랫폼에서 실행하고 있습니다. 이 오류 메시지는 다음을 표시합니다.
OSError: [Errno 9] 잘못된 파일 설명자
이 문제를 해결하는 방법은 무엇입니까? 이 오류의 원인은 무엇입니까?
오류 메시지는 다음과 같습니다.
C:\Users\ELCOT>python -m pip install -upgrade pip
Traceback (most recent call last):
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python37-32\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\cli\autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\cli\main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\commands\__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\commands\completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\cli\base_command.py", line 20, in <module>
from pip._internal.download import PipSession
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\download.py", line 15, in <module>
from pip._vendor import requests, six, urllib3
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\__init__.py", line 114, in <module>
from . import utils
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\utils.py", line 26, in <module>
from ._internal_utils import to_native_string
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str, str
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\compat.py", line 64, in <module>
from http.cookies import Morsel
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 859, in get_code
File "<frozen importlib._bootstrap_external>", line 917, in get_data
OSError: [Errno 9] Bad file descriptor
C:\Users\ELCOT>pip install numpy
Traceback (most recent call last):
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python37-32\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\cli\autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\cli\main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\commands\__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\commands\completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\cli\base_command.py", line 20, in <module>
from pip._internal.download import PipSession
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_internal\download.py", line 15, in <module>
from pip._vendor import requests, six, urllib3
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\__init__.py", line 114, in <module>
from . import utils
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\utils.py", line 26, in <module>
from ._internal_utils import to_native_string
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str, str
File "c:\users\elcot\appdata\local\programs\python\python37-32\lib\site-packages\pip\_vendor\requests\compat.py", line 64, in <module>
from http.cookies import Morsel
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 859, in get_code
File "<frozen importlib._bootstrap_external>", line 917, in get_data
OSError: [Errno 9] Bad file descriptor
답변1
최근(지난 3년 정도) Windows에서 랜섬웨어에 맞서기 위해 일부 보안 설정을 업데이트한 것 같습니다. 따라서 우리가 작성하는 프로그램(예: Python 프로그램)은 C:\Users\xxxxx\Documents 내부의 파일만 읽고 쓸 수 있습니다. 폴더.
저는 C:\working이라는 특수 작업 폴더를 만들고 재미로 모든 코딩 작업을 수행하곤 했는데, 이제 이 보안 업데이트로 인해 프로그램이 더 이상 작동하지 않습니다. 정확히 동일한 프로그램을 C:\Users\xxxxx\Documents로 옮기면 언제나처럼 작동합니다.