ModuleNotFoundError when trying to use pip-autoremove
Mia Lopez
I tried to install pip-autoremove and it was successfully installed. But when I tried pip-autoremove jupyter -y it gives me the following error:
Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\A\AppData\Local\Programs\Python\Python311\Scripts\pip-autoremove.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip_autoremove'I tried to check system path and I see I have C:\Users\A\AppData\Local\Programs\Python\Python311 and C:\Users\A\AppData\Local\Programs\Python\Python311\Scripts and C:\Users\A\AppData\Local\Programs\Python\Python311\Lib\site-packages available there!
Also the result for python -m ensurepip:
Looking in links: c:\Users\A\AppData\Local\Temp\tmp77qlwp70
Requirement already satisfied: setuptools in c:\users\a\appdata\local\programs\python\python311\lib\site-packages (65.5.0)
Requirement already satisfied: pip in c:\users\a\appdata\local\programs\python\python311\lib\site-packages (22.3.1)Moreover, pip install --upgrade pip couldn't help!
What is the problem?
21 Answer
This issue can be solved by moving the pip_autoremove.py file from its original (misplaced) location within the Scripts folder to the Lib folder within your Python program files.
More specifically, assuming you have Python 3.11.x installed, and if Python is installed for all users, then move the pip_autoremove.py file from:
C:\Program Files\Python311\Scripts to
C:\Program Files\Python311\LibAlternatively, if Python is installed for a specific user (e.g. Username), then move the pip_autoremove.py file from:
C:\Users\Username\AppData\Local\Programs\Python\Python311\Scriptsto
C:\Users\Username\AppData\Local\Programs\Python\Python311\LibYou can then run the command pip-autoremove --version in the command prompt and it should return pip-autoremove 0.10.0 if everything is working correctly. From there you can remove a package and its leftover dependencies with:
pip-autoremove.exe some_packageNoting that there are the following options should you need them:
Options: -l, --list list unused dependencies, but don't uninstall them. -L, --leaves list leaves (packages which are not used by any others). -y, --yes don't ask for confirmation of uninstall deletions. 2