[英]Pip error in python when importing modules from pip
當我從 pip 導入模塊時,像請求一樣,我在 VSCODE 中運行時收到此錯誤:
PermissionError: [WinError 32] 該進程無法訪問該文件,因為它正被另一個進程使用:C:\Users\user\AppData\Local\Temp\tmp_6yww79s
我使用的唯一代碼是: import requests
如果我使用 pip: pip --version
在終端或其他命令中檢查 pip 版本,我會收到相同的錯誤
完整錯誤:
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>
我遇到了同樣的問題,但錯誤是間歇性的。 如果您正確編碼文件打開/關閉但仍然遇到此錯誤,請確保您沒有將文件與 Dropbox、Google Drive 等同步。我暫停了 Dropbox,我不再看到該錯誤。
看起來問題來自 python-certifi-win32,如錯誤消息中所示。 要解決它,請使用下面的鏈接,這里有 python-certifi-win32 問題的解決方案。
如果這些解決方案不起作用,請搜索 python-certifi-win32 卸載和安裝過程。 最后但不推薦的解決方案卸載所有 python 文件和庫刪除配置文件、緩存和所有與 python 相關的文件並重新安裝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.