'Found existing installation', 'Not uninstalling', and 'Can[not] uninstall' Error Messages When Using 'Pip' to Install from a Local Filesystem

When running “pip” to install a package from a local file system, do you get messages like “Found existing installation package_name”, “Not uninstalling package_name”, “Can’t uninstall ‘package_name’“, “No files were found to uninstall”? This could be because you are trying to install the package from within the package root directory, and “pip” is confusing the (ephemeral/coincidental) package availability from the current working directory with the package being installed and available globally. That is, because “import packagename” happens to work from the current working directory (as it should, as due to the name being available from there), “pip” mistakenly assumes that the package has already been installed and attempts to uninstall it before proceeding. Of course, it probably has not, but “pip” does not know that without checking via potentially risk directory changing gymnastics, so it just declares the failure to uninstall (without going up one level from the current directory). Either way, though, the install will succeed, so it is probably no big deal.

However, in the interests of scratching the correctness itch, by invoking “pip” from one directory above and passing in the path to the installation source, you could avoid this issue.

So, instead of:

$ cd ~/projects/packagename
$ python3 -m pip install -e .


$ cd ~/projects
$ python3 -m pip install -e packagename