[Python] PermissionError: [WinError 32] when importing the requests module

Discussão em 'Python' iniciado por Stack, Julho 21, 2025.

  1. Stack

    Stack Membro Participativo

    When I run the command import requests, I get this:

    Traceback (most recent call last):
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 89, in _tempfile
    os.write(fd, reader())
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
    with self.open('rb') as strm:
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\importlib\_adapters.py", line 54, in open
    raise ValueError()
    ValueError

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 118, in <module>
    from . import utils
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 25, in <module>
    from . import certs
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\certs.py", line 15, in <module>
    from certifi import where
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 170, in exec_module
    notify_module_loaded(module)
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
    return wrapped(*args, **kwargs)
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
    hook(module)
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
    certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\core.py", line 37, in where
    _CACERT_PATH = str(_CACERT_CTX.__enter__())
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
    File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 95, in _tempfile
    os.remove(raw_path)
    PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\user1\\AppData\\Local\\Temp\\tmpz9h1wrjd'


    If I delete the file at the bottom of the error, it generates a new random file and the new file comes up in the error code.

    Continue reading...

Compartilhe esta Página