【问题标题】:pip error caused by installing Django 1.9安装 Django 1.9 导致的 pip 错误
【发布时间】:2016-03-15 13:32:03
【问题描述】:

似乎新的 django 已损坏并导致 pip 错误。我安装了 django 并出现语法错误:

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...

现在pip不工作了,我试过卸载新的django,卸载pip,然后重新安装pip,无济于事...

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

在 /home/cchilders/.pip/pip.log 中存储失败的调试日志

由于我已经删除了 django 1.9,我可以做些什么来恢复我的机器?谢谢

【问题讨论】:

标签: python django ubuntu pip django-1.9


【解决方案1】:

如果您不适合删除 python,请按照以下步骤操作。

  1. 删除点子 (sudo apt-get remove python-pip)
  2. 删除 Djano 软件包。 sudo rm -rf /usr/local/lib/python2.7/dist-packages/django/
  3. 重新安装 python。 sudo apt-get install --reinstall python2.7(如果您的版本是 2.7)
  4. 重新安装pip python get-pip.py
  5. 重新安装 Django(通常方式)

【讨论】:

    【解决方案2】:

    这看起来像 Django 1.9 发行说明中提到的 setuptools 问题:https://docs.djangoproject.com/en/1.9/releases/1.9/#syntaxerror-when-installing-django-setuptools-5-5-x

    在运行 pip install django 之前尝试运行 pip install -U pip

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-20
      • 1970-01-01
      • 2021-12-06
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      相关资源
      最近更新 更多