Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip uninstall working but giving error

I have downloaded, built and installed the sample pypi project. The project is supposed to be used to give an insight to python packaging and is referenced in Python Packaging User Guide and Packaging and Distributing Projects. I am therefore confused to why on earth following their instructions on creating the package I have an error when uninstalling it.

As mentioned above I have used their sample project. If anyone can shed some light it would be appreciated.

Key notes: I am running Mac OSX, my installed python version is 3.5.1 Below are steps to reproduce the problem:

mkdir testdirectory 
cd testdirectory/
pyvenv venv    # Creating a virtual environment
source venv/bin/activate
git clone https://github.com/pypa/sampleproject.git    # Getting sample project
cd sampleproject/
python setup.py build
python setup.py install    # Installing on the virtual environment

pip list
peppercorn (0.5)
pip (7.1.2)
sample (1.2.0)
setuptools (18.2)

pip uninstall sample

Resulting in the following output:

Uninstalling sample-1.2.0:
  /Users/steve/testdirectory/venv/bin/sample
  /Users/steve/testdirectory/venv/lib/python3.5/site-packages/sample-1.2.0-py3.5.egg
Proceed (y/n)? y
  Successfully uninstalled sample-1.2.0
Traceback (most recent call last):
  File "/Users/steve/testdirectory/venv/bin/pip3", line 11, in <module>
    sys.exit(main())
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/__init__.py", line 217, in main
    return command.main(cmd_args)
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/basecommand.py", line 248, in main
    pip_version_check(session)
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/utils/outdated.py", line 102, in pip_version_check
    installed_version = get_installed_version("pip")
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/utils/__init__.py", line 858, in get_installed_version
    working_set = pkg_resources.WorkingSet()
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 629, in __init__
    self.add_entry(entry)
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 685, in add_entry
    for dist in find_distributions(entry, True):
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2075, in find_eggs_in_zip
    if metadata.has_metadata('PKG-INFO'):
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1605, in has_metadata
    return self.egg_info and self._has(self._fn(self.egg_info, name))
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1963, in _has
    return zip_path in self.zipinfo or zip_path in self._index()
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1843, in zipinfo
    return self._zip_manifests.load(self.loader.archive)
  File "/Users/steve/testdirectory/venv/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1783, in load
    mtime = os.stat(path).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/Users/steve/testdirectory/venv/lib/python3.5/site-packages/sample-1.2.0-py3.5.egg'

It appears that the package has uninstalled correctly however the error is still thrown.

like image 971
SJC Avatar asked Jun 16 '16 10:06

SJC


2 Answers

This is documented:

$ pip help uninstall

Usage:
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

Description:
  Uninstall packages.

  pip is able to uninstall most installed packages. Known exceptions are:

  - Pure distutils packages installed with ``python setup.py install``, which
    leave behind no metadata to determine what files were installed.
  - Script wrappers installed by ``python setup.py develop``.

i.e. you are getting the error because you didn't use pip itself to install - you used setup.py and so pip doesn't know what was installed.

like image 91
msanders Avatar answered Sep 28 '22 02:09

msanders


Install package not with python setup.py install but with pip install .

Then uninstalling will work without errors

like image 22
vlk Avatar answered Sep 28 '22 01:09

vlk