0

When i import modules from pip, like requests i get this error when running in VSCODE:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: C:\Users\user\AppData\Local\Temp\tmp_6yww79s

The only code I used was: import requests

I get the same error if i check pip version in terminal or other commands with pip: pip --version

Full error:

PS C:\Script\Frost_met>  & 'C:\Users\jrf\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\jrf\.vscode\extensions\ms-python.python-2022.12.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '62406' '--' 'c:\Script\Frost_met\frost.py' 
Traceback (most recent call last):
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 89, in _tempfile
    os.write(fd, reader())
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
    with self.open('rb') as strm:
  File "C:\Users\jrf\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 "c:\Script\Frost_met\frost.py", line 4, in <module>
    import requests
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 147, in <module>
    from . import packages, utils
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 24, in <module>
    from . import certs
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\certs.py", line 14, 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\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
    notify_module_loaded(module)
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
    return wrapped(*args, **kwargs)
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded     
    hook(module)
  File "C:\Users\jrf\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\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\core.py", line 37, in where
    _CACERT_PATH = str(_CACERT_CTX.__enter__())
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "C:\Users\jrf\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\\jrf\\AppData\\Local\\Temp\\tmp23ldltgt'
PS C:\Script\Frost_met>
PS C:\Script\Frost_met>  & 'C:\Users\jrf\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\jrf\.vscode\extensions\ms-python.python-2022.12.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '62406' '--' 'c:\Script\Frost_met\frost.py' 
Traceback (most recent call last):
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 89, in _tempfile
    os.write(fd, reader())
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
    with self.open('rb') as strm:
  File "C:\Users\jrf\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 "c:\Script\Frost_met\frost.py", line 4, in <module>
    import requests
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 147, in <module>
    from . import packages, utils
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 24, in <module>
    from . import certs
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\certs.py", line 14, 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\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
    notify_module_loaded(module)
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
    return wrapped(*args, **kwargs)
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded     
    hook(module)
  File "C:\Users\jrf\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\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\core.py", line 37, in where
    _CACERT_PATH = str(_CACERT_CTX.__enter__())
  File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "C:\Users\jrf\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\\jrf\\AppData\\Local\\Temp\\tmp23ldltgt'
PS C:\Script\Frost_met>
Johs
  • 73
  • 1
  • 7

2 Answers2

2

Looks like the problem comes from python-certifi-win32, as seen in the error messages. To solve it use the link below there are solutions for python-certifi-win32 problem.

python-certifi-win32 problem with solutions

If these solutions don't work search for python-certifi-win32 uninstall and install process. Last but not recommended solution uninstall all python files and libraries delete config files, caches and all files related to python and reinstall.

Tunahan Akdogan
  • 246
  • 2
  • 9
0

I was running into the same problem, but the error was intermittent. If you are coding your file open/close correctly and still running into this error, make sure you are not synching the files with Dropbox, Google Drive, etc. I paused Dropbox and I no longer see the error.

Kritarth
  • 48
  • 11
  • Thanks. I tried stopping my internet connection, but I get the same error. I got my python scripts located on my C folder and newer had this problem before :S – Johs Aug 12 '22 at 14:31