I am trying to uninstall pdfminer.six
package with pip. I execute the command:
pip uninstall pdfminer.six
The full output is as follows:
Found existing installation: pdfminer.six -VERSION-
Uninstalling pdfminer.six--VERSION-:
Would remove:
/usr/lib/python3/dist-packages/pdfminer
/usr/lib/python3/dist-packages/pdfminer.six-_VERSION_.egg-info
Proceed (Y/n)? Y
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.10/shutil.py", line 816, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pdfminer' -> '/tmp/pip-uninstall-ljfekdq7'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 106, in _run_wrapper
status = _inner_run()
File "/home/user/.local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 97, in _inner_run
return self.run(options, args)
File "/home/user/.local/lib/python3.10/site-packages/pip/_internal/commands/uninstall.py", line 106, in run
uninstall_pathset = req.uninstall(
File "/home/user/.local/lib/python3.10/site-packages/pip/_internal/req/req_install.py", line 723, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/home/user/.local/lib/python3.10/site-packages/pip/_internal/req/req_uninstall.py", line 370, in remove
moved.stash(path)
File "/home/user/.local/lib/python3.10/site-packages/pip/_internal/req/req_uninstall.py", line 261, in stash
renames(path, new_path)
File "/home/user/.local/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 350, in renames
shutil.move(old, new)
File "/usr/lib/python3.10/shutil.py", line 834, in move
rmtree(src)
File "/usr/lib/python3.10/shutil.py", line 725, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib/python3.10/shutil.py", line 681, in _rmtree_safe_fd
onerror(os.unlink, fullname, sys.exc_info())
File "/usr/lib/python3.10/shutil.py", line 679, in _rmtree_safe_fd
os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'layout.py'
Same error [Errno 13] Permission denied
happens when I try to uninstall some other pdf-related packages, such as ocrmypdf
and pikepdf
(only the file that the system can't access is different). What is the problem? How can I uninstall the packages?
Some details:
python3 -V
is Python 3.10.12
;pip -V
is pip 25.0.UPD: Thank you for all the answers! Before posting the questions, I have tried:
sudo pip uninstall pdfminer.six
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
sudo apt remove python3-pdfminer.six
, sudo apt remove python-pdfminer.six
I should have put it initially in the question. My apologies.
Packages in /usr/lib/python3/dist-packages/
are installed either by the system package manager (apt
/apt-get/etc in your case) or by
pip. Whatever was the installation method root access is required so it either was
sudo apt installor
sudo pip install`.
To uninstall you also need root. If it was an apt
-installed package its name is python3-pdfminer
. If it was pip
-installed the package is named pdfminer.six
. So try one of these commands:
sudo apt remove python3-pdfminer
sudo pip uninstall pdfminer.six