Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionError when trying to uninstall dependent packages using pip-autoremove 0.10.1 on Windows #48

Open
zhmlcg opened this issue Feb 3, 2022 · 2 comments

Comments

@zhmlcg
Copy link

zhmlcg commented Feb 3, 2022

I installed pip-autoremove 0.10.1 (tresni/pip-autoremove) using command pip3 install git+https://github.com/tresni/pip-autoremove.git. Then, when I ran pip-autoremove to tried to remove package jupyterlab together with all its dependent packages, I got the following error:

... ...
... ... // many dependent packages of jupyterlab like Pygments-2.11.2 were successfully uninstalled
... ... 
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\base_command.py", line 165, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\uninstall.py", line 102, in run
    uninstall_pathset.commit()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_uninstall.py", line 420, in commit
    self._moved_paths.commit()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\req\req_uninstall.py", line 273, in commit
    save_dir.cleanup()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\utils\temp_dir.py", line 173, in cleanup
    rmtree(self._path)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 326, in wrapped_f
    return self(f, *args, **kw)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 406, in __call__
    do = self.iter(retry_state=retry_state)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 362, in iter
    raise retry_exc.reraise()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 195, in reraise
    raise self.last_attempt.result()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result
    raise self._exception
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 409, in __call__
    result = fn(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\utils\misc.py", line 124, in rmtree
    shutil.rmtree(dir, ignore_errors=ignore_errors, onerror=rmtree_errorhandler)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 739, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 617, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 615, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\~ywin32_system32\\pythoncom310.dll'
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\Scripts\pip-autoremove.exe\__main__.py", line 7, in <module>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\Scripts\pip_autoremove.py", line 164, in main
    autoremove(args, yes=opts.yes)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\Scripts\pip_autoremove.py", line 45, in autoremove
    remove_dists(dead)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\Scripts\pip_autoremove.py", line 123, in remove_dists
    subprocess.check_call(pip_cmd + ["uninstall", "-y"] + [d.project_name for d in dists])
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\python.exe', '-m', 'pip', 'uninstall', '-y', 'Pygments', 'mypy-extensions', 'colorama', 'pywin32', 'jsonschema', 'wcwidth', 'pyzmq', 'notebook', 'ipykernel', 'packaging', 'nbconvert', 'attrs', 'pathspec', 'jupyter-client', 'jupyter-core', 'defusedxml', 'asttokens', 'nbclassic', 'json5', 'pytz', 'ipython', 'jupyterlab', 'parso', 'entrypoints', 'testpath', 'nbformat', 'prometheus-client', 'click', 'debugpy', 'nest-asyncio', 'terminado', 'sniffio', 'mistune', 'jupyter-server', 'python-dateutil', 'argon2-cffi-bindings', 'argon2-cffi', 'ipython-genutils', 'jupyterlab-server', 'backcall', 'matplotlib-inline', 'Jinja2', 'Babel', 'pyparsing', 'Send2Trash', 'nbclient', 'prompt-toolkit', 'pickleshare', 'webencodings', 'MarkupSafe', 'pandocfilters', 'platformdirs', 'pure-eval', 'anyio', 'stack-data', 'executing', 'pywinpty', 'traitlets', 'pyrsistent', 'black', 'pycparser', 'tornado', 'decorator', 'jedi', 'cffi', 'tomli', 'jupyterlab-pygments', 'websocket-client', 'bleach']' returned non-zero exit status 2.

I ran the cmd with Administrator privilege, so I have no idea why the permission error and how to fix this. Since tresni/pip-autoremove does not have Issues tab, I asked here. Thanks for your help.

My environment:

  • Windows 10
  • Python 3.10

PS, as a side question, do I have to reinstall jupyterlab to continue uninstalling its dependent packages successfully?

@me21
Copy link

me21 commented May 26, 2022

I have this issue too. I think it is related to a specific package - pywin32 - that throws errors when being uninstalled by pip-autoremove, but I may be mistaken.

@bestagi
Copy link

bestagi commented Aug 13, 2023

I faced pretty much the same problem.
error code
The 'pywin32>=300; sys_platform == "win32" and platform_python_implementation != Distribution "PyPy"' not found and required by application

The proper pip-autoremove requires pywin32 but you end up running pip-autoremove jupyterlab which removes pywin32 from pip. to fix it just reinstall pywin32 with pip install pywin32 and you're all set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants