Search code examples
pythonpippackagesetuptoolsuninstallation

Calling `pip uninstall` from the source folder where `setup.py install` was called


If I clone a repos that uses setuptools, I can install it using python3 setup.py install --user.

For example:

git clone https://github.com/pybliometrics-dev/pybliometrics
cd pybliometrics
python3 setup.py install --user

However, I cannot pip uninstall it anymore. In fact:

$ pip3 uninstall pybliometrics
Found existing installation: pybliometrics 3.2.1.dev2
Can't uninstall 'pybliometrics'. No files were found to uninstall.

I have to change directory for the uninstallation command to be successful. Then change directory back if I want to reinstall it.

Why is that?

How can I uninstall from the same folder that I used to install it?

Here is the output of pip show as asked in the comment:

$ pip show -f pybliometrics
Name: pybliometrics
Version: 3.2.1.dev2
Summary: Python-based API-Wrapper to access Scopus
Home-page: https://pybliometrics.readthedocs.io/en/stable/
Author: 'John Kitchin and Michael E. Rose
Author-email: [email protected]
License: MIT
Location: /run/media/MYNAME/MYID/data/progetti_miei/pybliometrics
Requires: pbr, requests, simplejson, tqdm
Required-by: 
Files:
Cannot locate RECORD or installed-files.txt

Solution

  • In the output of the pip show -f pybliometrics command, we can read:

    Files:
    Cannot locate RECORD or installed-files.txt
    

    This might explain why it can not be uninstalled. And I am not sure how this happened, nor how to fix it.

    But with that said, here are some notes:

    1. The commands shown in your question are inconsistent. On one hand you call pip show -f pybliometrics and on the other you call pip3 uninstall pybliometrics. But pip and pip3 are not necessarily the same thing, and do not necessarily interact with the same projects.

    2. Do not use python setup.py install. Calling the setup.py is now deprecated, the recommended way of installing a Python project is via pip.

    3. One should never call the pip scripts directly, but should always prefer explicitly calling the pip executable module with the targeted Python interpreter (see this reference article and this other answer for details).

    So in your case what you probably should have done (no guarantee it would have solved your issue, but it would have minimized risks):

    • Clearly identify which Python interpreter you want to use, let's say it is path/to/bin/pythonX.Y
    • Install project with: path/to/bin/pythonX.Y -m pip install --user path/to/pybliometrics
    • Check installed project with path/to/bin/pythonX.Y -m pip show -f pybliometrics
    • Uninstall project with: path/to/bin/pythonX.Y -m pip uninstall pybliometrics