Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip freeze lists uninstalled packages

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?

like image 995
MLister Avatar asked Jul 24 '12 23:07

MLister


People also ask

How do I remove an uninstalled package from pip?

To use pip to uninstall a package locally in a virtual environment: Open a command or terminal window (depending on the operating system) cd into the project directory. pip uninstall <packagename>

Does pip freeze show dependencies?

As I said above, running pip freeze gives you a list of all currently installed dependencies, but that does mean all of them.

What is the difference between pip freeze and pip list?

The difference between pip freeze and pip list is that: pip freeze outputs the installed by the user packages in a requirements format that can be used to generate a requirements. txt file. pip list outputs all installed packages, including editables.

Should I use pip freeze?

pip freeze might seem very useful initially but it can mess up your project because of the following reasons: It dumps all the libraries installed in your project including dependencies and sub-dependencies in the requirements. txt file. It still misses out on the libraries that are not installed using pip.


1 Answers

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.

like image 70
Hugo Tavares Avatar answered Nov 14 '22 22:11

Hugo Tavares