codyc4321
codyc4321

Reputation: 9682

pip error caused by installing Django 1.9

it seems the new django is broken and causing errors with pip. I did an install of django and got syntax error:

cchilders@main:~/projects$ sudo pip install django
Downloading/unpacking django
  Downloading Django-1.9-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
Compiling /tmp/pip-build-3WZoMx/django/django/conf/app_template/apps.py ...
  File "/tmp/pip-build-3WZoMx/django/django/conf/app_template/apps.py", line 4
    class {{ camel_case_app_name }}Config(AppConfig):
          ^
SyntaxError: invalid syntax

Compiling /tmp/pip-build-3WZoMx/django/django/conf/app_template/models.py ...
  File "/tmp/pip-build-3WZoMx/django/django/conf/app_template/models.py", line 1
    {{ unicode_literals }}from django.db import models
                             ^
SyntaxError: invalid syntax

Successfully installed django
Cleaning up...

Now pip doesn't work, and I've tried uninstalling the new django, uninstalling pip, then reinstalling pip, to no avail...

cchilders@main:~/projects$ pip freeze
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/freeze.py", line 74, in run
    req = pip.FrozenRequirement.from_dist(dist, dependency_links, find_tags=find_tags)
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 299, in from_dist
    assert len(specs) == 1 and specs[0][0] == '=='
AssertionError

Storing debug log for failure in /home/cchilders/.pip/pip.log

Since I've already removed django 1.9, what can I do to restore my machine? Thank you

Upvotes: 1

Views: 1125

Answers (2)

Romaan
Romaan

Reputation: 2757

This looks like the setuptools issue mentioned in the Django 1.9 release notes: https://docs.djangoproject.com/en/1.9/releases/1.9/#syntaxerror-when-installing-django-setuptools-5-5-x

Try to run pip install -U pip before running pip install django

Upvotes: 4

JGCW
JGCW

Reputation: 1529

Follow the following steps if removing python is not an option for you.

  1. Remove pip (sudo apt-get remove python-pip)
  2. Remove Djano packages. sudo rm -rf /usr/local/lib/python2.7/dist-packages/django/
  3. Reinstall python. sudo apt-get install --reinstall python2.7 (if your version is 2.7)
  4. Reinstall pip python get-pip.py
  5. Reinstall Django (usual way)

Upvotes: 1

Related Questions