Search code examples
pythondjangopipansiblesetuptools

Pip is rolling back uninstall of setuptools


I am using this Ansible-Django stack to deploy my Django project to an AWS EC2 instance. It worked fine for a long time, but now suddenly, I get the error below when deploying.

It seems like there is a new setuptools build that is not properly updated.

  • Why does it rollback the uninstall of setuptools?
  • Why does it not install setuptools 36.2.2?

Specifying explicitly the version of setuptools in my requirements solves this issue, but since I am only indirectly dependent on setuptools, it should not be my responsibility to know which version to keep.

Installing collected packages: shared-django, setuptools
  Found existing installation: shared-django 0.1.0
    Uninstalling shared-django-0.1.0:
      Successfully uninstalled shared-django-0.1.0
  Running setup.py install for shared-django: started
    Running setup.py install for shared-django: finished with status 'done'
  Found existing installation: setuptools 36.2.0
    Uninstalling setuptools-36.2.0:
      Successfully uninstalled setuptools-36.2.0
  Rolling back uninstall of setuptools

:stderr: Exception:
Traceback (most recent call last):
  File \"/webapps/CatalogService/lib/python3.5/site-packages/pip/basecommand.py\", line 215, in main
    status = self.run(options, args)
  File \"/webapps/CatalogService/lib/python3.5/site-packages/pip/commands/install.py\", line 342, in run
    prefix=options.prefix_path,
  File \"/webapps/CatalogService/lib/python3.5/site-packages/pip/req/req_set.py\", line 784, in install
    **kwargs
  File \"/webapps/CatalogService/lib/python3.5/site-packages/pip/req/req_install.py\", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File \"/webapps/CatalogService/lib/python3.5/site-packages/pip/req/req_install.py\", line 1064, in move_wheel_files
    isolated=self.isolated,
  File \"/webapps/CatalogService/lib/python3.5/site-packages/pip/wheel.py\", line 247, in move_wheel_files
    prefix=prefix,
  File \"/webapps/CatalogService/lib/python3.5/site-packages/pip/locations.py\", line 140, in distutils_scheme
    d = Distribution(dist_args)
  File \"/webapps/CatalogService/lib/python3.5/site-packages/setuptools/dist.py\", line 365, in __init__
    self._finalize_requires()
  File \"/webapps/CatalogService/lib/python3.5/site-packages/setuptools/dist.py\", line 372, in _finalize_requires
    if not self.install_requires:
AttributeError: 'Distribution' object has no attribute 'install_requires'

Solution

  • I had to ssh into the server and run

    python -m pip install --upgrade -vv setuptools

    and then I deployed again and it worked.