[Solved] Can’t uninstall project with no packages


The steps shown in the question will actually create and install a real package. It won’t create any importable files, but it will create metadata in a site-packages directory. Exactly where it has installed depends on your USER_SITE configuration, which you can check with python3.6 -m site, but it’s probably going to be at ~/.local/lib/python3.6/site-packages/example-0.0.0-py3.6.egg-info.

Path files (.pth) are unrelated.

The reason it can’t uninstall, saying:

Can’t uninstall ‘example’. No files were found to uninstall.

is because the build command executed earlier will have created an example.egg-info in the current directory, and using python3.6 -m pip means the empty-string is in sys.path. So, the current directory is also considered a package location. Since the current working directory, at sys.path[0], is before the user site the example.egg-info metadata will be found here instead of in site-packages.

The command python3.6 -m pip uninstall also finds this build artifact first, for the same reasons, and does not find the metadata from site-packages which has a record of the files that should be removed during an uninstall. To correctly uninstall this package you could:

rm -rf example.egg-info   # first prevent pip from getting confused by the temporary build artifact in cwd
python3.6 -m pip uninstall example  # uninstall it from the user site

Or, you could change directory before uninstalling, so that pip finds the package metadata for example in the user site instead of in the working directory.

Note 1: These workarounds are not required for pip >= 20.1. Since April 2020, using python -m pip now ejects the cwd from sys.path and it will uninstall successfully from the user site in the first place without getting confused (#7731)

Note 2: some details are slightly different if this python3.6 environment has a wheel installation in it – in this case the install command will first create a wheel file from the sdist, and then install the wheel, which will result in an example-0.0.0.dist-info subdirectory for the metadata instead of an egg-info subdirectory, but the important details are the same whether you have an .egg-info or .dist-info style install in the user site. It is not possible to determine from the details in the question whether the python3.6 environment had a wheel installation available.

0

solved Can’t uninstall project with no packages