pip freeze lists uninstalled packages

笑着哭i 提交于 2019-12-10 14:07:24

问题


On OS X 10.6.8, I uninstalled a package using (at least pip tells me so)

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.

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?


回答1:


I thought you may have two pip binaries, and when you run as sudo, your shell chooses the wrong one, at first. But it does not make any sense if you run it again as sudo and pip removed the package. 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. 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.




回答2:


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!



回答3:


If you use a virtual environment, try clean command. Don't forget sudo.

sudo pipenv clean


来源:https://stackoverflow.com/questions/11640530/pip-freeze-lists-uninstalled-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!