简体   繁体   English

pip freeze列出了已卸载的软件包

[英]pip freeze lists uninstalled packages

On OS X 10.6.8, I uninstalled a package using (at least pip tells me so) 在OS X 10.6.8上,我使用(至少pip告诉我)卸载了一个包

sudo pip uninstall pkg_name

but the package still shows up when I do 但是当我这样做时,包裹仍会出现

pip freeze

I try to do the uninstall command above again, and pip tells me the package is not installed. 我尝试再次执行上面的卸载命令,并且pip告诉我没有安装包。

What is the problem here? 这里有什么问题? How do I verify whether the package is uninstalled or not? 如何验证软件包是否已卸载? If so, can I refresh some sort of index of pip to get it corrected? 如果是这样,我可以刷新某种pip索引来纠正吗?

I thought you may have two pip binaries, and when you run as sudo , your shell chooses the wrong one, at first. 我以为你可能有两个pip二进制文件,当你以sudo运行时,你的shell首先会选择错误的一个。 But it does not make any sense if you run it again as sudo and pip removed the package. 但是,如果再次运行它,因为sudopip删除了包,这没有任何意义。 Did you do exactly this? 你做到了吗?

If you did not run the same commands twice, you may have different pip binaries running the uninstall and freeze. 如果您没有运行两次相同的命令,则可能有不同的pip二进制文件运行卸载和冻结。 Check if the following two commands result in the same output: 检查以下两个命令是否产生相同的输出:

$ sudo pip freeze
# ... sudo output
$ pip freeze
# ... normal output

Anyway, you can check if the package is installed using: 无论如何,您可以使用以下方法检查包是否已安装:

$ python -c 'import pkg_name' &> /dev/null && echo installed || echo not installed

There is no sort of refresh feature in pip . pip没有任何刷新功能。

I had this same problem and it was due to broken symlinks from homebrew once the file was uninstalled. 我有同样的问题,这是因为卸载文件后,自制程序中的符号链接已损坏。

$ pip freeze | grep Magic
Magic-file-extensions==0.2

$ pip uninstall Magic-file-extensions
# say `y` at prompt / see it go through as success

$ pip freeze | grep Magic # still there :(
Magic-file-extensions==0.2

$ ll /usr/local/lib/python2.7/site-packages/ | grep Magic # symlink shows up red
├── [lrwxr-xr-x tomfuert   98 Feb 16 11:06]  Magic_file_extensions-0.2-py2.7.egg-info -> ../../../Cellar/libmagic/5.17/lib/python2.7/site-packages/Magic_file_extensions-0.2-py2.7.egg-info

$ rm /usr/local/lib/python2.7/site-packages/Magic_file_extensions-0.2-py2.7.egg-info

$ pip freeze | grep Magic
# nothing!

If you use a virtual environment, try clean command. 如果您使用虚拟环境,请尝试使用clean命令。 Don't forget sudo. 别忘了sudo。

sudo pipenv clean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM