Pip is broken, gives PermissionError: [WinError 32]

2024/10/18 14:58:50

I installed the python-certifi-win32 module (I'm so busy trying to fix this problem that I don't even remember why I originally installed it). Right after I installed it, though, I started getting this error when I run pip (extended error code below): PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\user1\\AppData\\Local\\Temp\\tmph93rz74c' When I delete the file C:\\Users\\user1\\AppData\\Local\\Temp\\tmph93rz74c, another file pops up in its place, just with a different random combination of letters and numbers, and the error says the new file name instead. I have no idea how to fix it, my pip hasn't been working for days. I've looked through tens of pages of google results.

Full error code:

Traceback (most recent call last):File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_mainreturn _run_code(code, main_globals, None,File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_codeexec(code, run_globals)File "C:\Users\user1\AppData\Local\Programs\Python\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>from pip._internal.cli.autocompletion import autocompleteFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>from pip._internal.cli.main_parser import create_main_parserFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>from pip._internal.cli import cmdoptionsFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>from pip._internal.cli.parser import ConfigOptionParserFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>from pip._internal.configuration import Configuration, ConfigurationErrorFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>from pip._internal.exceptions import (File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>from pip._vendor.requests.models import Request, ResponseFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\requests\__init__.py", line 135, in <module>from . import utilsFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\requests\utils.py", line 27, in <module>from . import certsFile "<frozen importlib._bootstrap>", line 1027, in _find_and_loadFile "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 688, in _load_unlockedFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 170, in exec_modulenotify_module_loaded(module)File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronizedreturn wrapped(*args, **kwargs)File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loadedhook(module)File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi_win32\wrapt_pip.py", line 35, in apply_patchesimport certifiFile "<frozen importlib._bootstrap>", line 1027, in _find_and_loadFile "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 688, in _load_unlockedFile "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 170, in exec_modulenotify_module_loaded(module)File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronizedreturn wrapped(*args, **kwargs)File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loadedhook(module)File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patchescertifi_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 _tempfileos.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\\tmph93rz74c'
Answer

I ran into the same problem after installing python-certifi-win32. I installed this package in the hope to solve errors caused by the self-signed certificate used by our SSL Inspection infrastructure.

To bring pip back to a running state remove python-certifi-win32 from the installation folder:

  • Determine the installation path for pip packages (source):

    python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
    
  • Switch to the folder and delete the package's files:

    del python-certifi-win32-init.pth
    rmdir /s/q python_certifi_win32-1.6.dist-info
    
https://en.xdnf.cn/q/73170.html

Related Q&A

Pandas highlight rows based on index name

I have been struggling with how to style highlight pandas rows based on index names. I know how to highlight selected rows but when I have to highlight based on the index, the code is not working.Setup…

Histogram of sum instead of count using numpy and matplotlib

I have some data with two columns per row. In my case job submission time and area.I have used matplotlibs hist function to produce a graph with time binned by day on the x axis, and count per day on t…

Find subsequences of strings within strings

I want to make a function which checks a string for occurrences of other strings within them. However, the sub-strings which are being checked may be interrupted within the main string by other letters…

How to bestow string-ness on my class?

I want a string with one additional attribute, lets say whether to print it in red or green.Subclassing(str) does not work, as it is immutable. I see the value, but it can be annoying.Can multiple inhe…

How to pass Python instance to C++ via Python/C API

Im extending my library with Python (2.7) by wrapping interfaces with SWIG 2.0, and have a graph object in which I want to create a visitor. In C++, the interface looks like this:struct Visitor{virtua…

REST API in Python with FastAPI and pydantic: read-only property in model

Assume a REST API which defines a POST method on a resource /foos to create a new Foo. When creating a Foo the name of the Foo is an input parameter (present in the request body). When the server creat…

a class with all static methods [closed]

Closed. This question is opinion-based. It is not currently accepting answers.Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.Clo…

How can I find null values with SELECT query in psycopg?

I am using psycopg2 library in python and the INSERT query works good when I insert null Value with None, but when I want to do SELECT null values, with None doesnt return any.cur.execute("SELECT …

Pause and continue stopwatch

I am trying to create stopwatch. I have done it but I would like to pause and continue the time whenever I want. I have tried some things but I have no idea how to do it. Is there anybody who would exp…

How do I escape `@` letter from SQL password in connection URI [duplicate]

This question already has an answer here:handle @ in mongodb connection string(1 answer)Closed 9 years ago.when you connect to mongodb using python from SQLAlchamey, we use mongodb://username:password@…