Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstall method? #281

Open
castillohair opened this issue Dec 31, 2017 · 1 comment
Open

Uninstall method? #281

castillohair opened this issue Dec 31, 2017 · 1 comment

Comments

@castillohair
Copy link
Collaborator

I cannot find a explicit statement about how to cleanly uninstall packages that have been installed with python setup.py install. Some people suggest pip uninstall [package-name], but some people mention that issues can arise (see https://stackoverflow.com/questions/1550226/python-setup-py-uninstall). In my hands, the following happens:

$ sudo pip uninstall FlowCal
Uninstalling FlowCal-1.1.4:
  /usr/local/lib/python2.7/dist-packages/FlowCal-1.1.4-py2.7.egg
Proceed (y/n)? y
  Successfully uninstalled FlowCal-1.1.4
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 233, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 252, in main
    pip_version_check(session)
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/outdated.py", line 102, in pip_version_check
    installed_version = get_installed_version("pip")
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/__init__.py", line 838, in get_installed_version
    working_set = pkg_resources.WorkingSet()
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 644, in __init__
    self.add_entry(entry)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 700, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1949, in find_eggs_in_zip
    if metadata.has_metadata('PKG-INFO'):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1463, in has_metadata
    return self.egg_info and self._has(self._fn(self.egg_info, name))
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1823, in _has
    return zip_path in self.zipinfo or zip_path in self._index()
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1703, in zipinfo
    return self._zip_manifests.load(self.loader.archive)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1643, in load
    mtime = os.stat(path).st_mtime
OSError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/FlowCal-1.1.4-py2.7.egg'

File /usr/local/lib/python2.7/dist-packages/FlowCal-1.1.4-py2.7.egg is there before the uninstall command is executed, but not after. Everything looks like FlowCal has been successfully uninstalled after running this command (cannot import from the python prompt, pip install python from anywhere works, etc). So it seems like uninstalling is successful, it just raises that ugly error message, maybe from trying to delete that file twice.

However, if I install FlowCal with the following command:

$ sudo pip install .

Uninstalling proceeds without any issues:

$ sudo pip uninstall FlowCal
Uninstalling FlowCal-1.1.4:
  /usr/local/lib/python2.7/dist-packages/FlowCal-1.1.4-py2.7.egg-info
  /usr/local/lib/python2.7/dist-packages/FlowCal/__init__.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/__init__.pyc
  /usr/local/lib/python2.7/dist-packages/FlowCal/excel_ui.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/excel_ui.pyc
  /usr/local/lib/python2.7/dist-packages/FlowCal/gate.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/gate.pyc
  /usr/local/lib/python2.7/dist-packages/FlowCal/io.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/io.pyc
  /usr/local/lib/python2.7/dist-packages/FlowCal/mef.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/mef.pyc
  /usr/local/lib/python2.7/dist-packages/FlowCal/plot.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/plot.pyc
  /usr/local/lib/python2.7/dist-packages/FlowCal/stats.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/stats.pyc
  /usr/local/lib/python2.7/dist-packages/FlowCal/transform.py
  /usr/local/lib/python2.7/dist-packages/FlowCal/transform.pyc
Proceed (y/n)? y
  Successfully uninstalled FlowCal-1.1.4

This was all done in Linux Mint 18.

So the following questions arise:

  • Is there a better method for uninstalling packages installed with python setup.py install? I haven't found it but I'll keep looking.
  • If we don't find anything, pip install . seems to be a better installation method than python setup.py install in terms of cleanliness when uninstalling. Do we want to change our recommendation in the documentation? Do we want to change it in the Windows and OSX installation scripts?
@JS3xton
Copy link
Contributor

JS3xton commented Dec 31, 2017

The posts I'm reading indeed endorse the use of pip (or, just generally some kind of package manager) over directly calling setup.py, so endorsing the use of a package manager seems like a good idea to me.

It looks like we're already kinda doing that in the documentation for manual installation? Might be nice to more clearly lay out our recommendation (i.e. "use a package manager", and then show them how), and only if a package manager is unavailable should you use python setup.py install. Maybe also put a Note/Warning in the documentation that if you install FlowCal via python setup.py install, you may have trouble uninstalling it (but again, we recommend using a package manager, even though it may throw errors).

I think pip is a good choice of package manager on Linux. I think it should work on OSX as well? Windows is a little trickier: I use Anaconda, which has its own package manager (conda). I believe you can still call pip in Anaconda (https://conda.io/docs/user-guide/tasks/manage-pkgs.html#installing-non-conda-packages), but it might be a better idea to use conda if we can figure out how.

In the automated scripts, perhaps you can try to use pip (or conda, depending on system), and if that fails, default back to calling setup.py manually?

Should we add "Uninstall" scripts? My initial feeling is that we probably should if we want to be consistent about making the user experience as painless as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants