我尝试安装pip-autoremove
并且它已成功安装。但是当我尝试pip-autoremove jupyter -y
时,它给了我以下错误:
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:UsersAAppDataLocalProgramsPythonPython311Scriptspip-autoremove.exe__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip_autoremove'
我试图检查系统路径,我看到我有C:UsersAAppDataLocalProgramsPythonPython311
和C:UsersAAppDataLocalProgramsPythonPython311Scripts
和C:UsersAAppDataLocalProgramsPythonPython311Libsite-packages
可用!
还有python -m ensurepip
的结果:
Looking in links: c:UsersAAppDataLocalTemptmp77qlwp70
Requirement already satisfied: setuptools in c:usersaappdatalocalprogramspythonpython311libsite-packages (65.5.0)
Requirement already satisfied: pip in c:usersaappdatalocalprogramspythonpython311libsite-packages (22.3.1)
而且,pip install --upgrade pip
也无能为力!
有什么问题吗?
这个问题可以通过将pip_autoremove.py
文件从Scripts
文件夹中的原始(错位)位置移动到Python程序文件中的Lib
文件夹中来解决。
更具体地说,假设您有Python 3.11。如果为所有用户安装了Python,那么将pip_autoremove.py
文件从:
C:Program FilesPython311Scripts
C:Program FilesPython311Lib
或者,如果Python是为特定用户安装的(例如Username
),那么将pip_autoremove.py
文件从:
C:UsersUsernameAppDataLocalProgramsPythonPython311Scripts
C:UsersUsernameAppDataLocalProgramsPythonPython311Lib
您可以在命令提示符中运行命令pip-autoremove --version
,如果一切正常,它应该返回pip-autoremove 0.10.0
。从这里你可以删除一个包和它剩下的依赖:
pip-autoremove.exe some_package
请注意,如果需要,有以下选项:
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.