I can install a package:
pip install brotli
but if I try to remove, it fails:
PS D:\Desktop> pip uninstall -y brotli
Found existing installation: Brotli 1.0.9
Uninstalling Brotli-1.0.9:
Successfully uninstalled Brotli-1.0.9
ERROR: Exception:
Traceback (most recent call last):
File "C:\python\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "C:\python\lib\site-packages\pip\_internal\commands\uninstall.py", line 102, in run
uninstall_pathset.commit()
File "C:\python\lib\site-packages\pip\_internal\req\req_uninstall.py", line 420, in commit
self._moved_paths.commit()
File "C:\python\lib\site-packages\pip\_internal\req\req_uninstall.py", line 273, in commit
save_dir.cleanup()
File "C:\python\lib\site-packages\pip\_internal\utils\temp_dir.py", line 173, in cleanup
rmtree(self._path)
File "C:\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 326, in wrapped_f
return self(f, *args, **kw)
File "C:\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 406, in __call__
do = self.iter(retry_state=retry_state)
File "C:\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 362, in iter
raise retry_exc.reraise()
File "C:\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 195, in reraise
raise self.last_attempt.result()
File "concurrent\futures\_base.py", line 439, in result
File "concurrent\futures\_base.py", line 391, in __get_result
File "C:\python\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 409, in __call__
result = fn(*args, **kwargs)
File "C:\python\lib\site-packages\pip\_internal\utils\misc.py", line 124, in rmtree
shutil.rmtree(dir, ignore_errors=ignore_errors, one rror=rmtree_errorhandler)
File "shutil.py", line 747, in rmtree
File "shutil.py", line 617, in _rmtree_unsafe
File "shutil.py", line 615, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Windows\\Temp\\pip-uninstall-fi5xmcvd\\_brotli.cp310-win_amd64.pyd'
whats strange is that after the failure, I can go back and manually remove the folder with no problem:
PS D:\Desktop> python.exe
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.rmtree('C:\\Windows\\Temp\\pip-uninstall-fi5xmcvd')
I am using python on windows
CodePudding user response:
Since it is giving you a permissions error try launching cmd as admin. Then flag it with m to see if it works.
python -m pip uninstall brotli
CodePudding user response:
The problem is in the Pip code, here [1]:
from pip._vendor.requests.models import Request, Response
As soon as that import happens, the brotli file is imported by pip itself, and so it cant be deleted until pip exits. This is a pip issue, not an error with brotli or any other package.