【问题标题】:SyntaxError in static.py when installing django-toolbelt安装 django-toolbelt 时 static.py 中的 SyntaxError
【发布时间】:2013-10-28 04:57:19
【问题描述】:

我正在将我的网站部署到 heroku。成功创建 virtualenv 后,我在这个 virtualenv 中使用“pip install django-toolbelt”安装 django-toolbelt 时遇到了问题。

一开始一切都很好,直到:

  Running setup.py install for static
      File "/home/administrator/env2/env2_env/lib/python3.2/site-packages/static.py", line 104
        if full_path[-1] <> '/' or full_path == self.root:
                          ^
    SyntaxError: invalid syntax


    Installing static script to /home/administrator/env2/env2_env/bin
Successfully installed django-toolbelt django psycopg2 gunicorn dj-database-url dj-static static
Cleaning up...

我知道错误的原因是比较运算符&lt;&gt;在python3.2中无效。我关心的是安装是否成功,尽管屏幕上显示的是“成功安装 django-toolbelt ...”。
如果没有,我该怎么做才能解决这个问题?谢谢。

【问题讨论】:

  • 请接受将您的问题标记为已解决的答案(这是一个社区 wiki 帖子,我不会获得任何声誉,别担心 :))

标签: django heroku deployment django-deployment


【解决方案1】:

我手动将运算符&lt;&gt; 替换为!=,并再次运行pip install django-toolbelt。然后另一个 static.py 文件出现了同样的错误:

  Running setup.py install for static
      File "/usr/local/lib/python3.2/site-packages/static.py", line 104
        if full_path[-1] <> '/' or full_path == self.root:
                          ^
    SyntaxError: invalid syntax


    Installing static script to /usr/local/bin
Successfully installed django-toolbelt gunicorn dj-database-url dj-static static
Cleaning up...

然后我在该 static.py 文件中再次将运算符 &lt;&gt; 更改为 !=。然后再次运行pip install django-toolbelt。现在没有显示错误:

Requirement already satisfied (use --upgrade to upgrade): django-toolbelt in /usr/local/lib/python3.2/site-packages
Requirement already satisfied (use --upgrade to upgrade): django in /usr/local/lib/python3.2/site-packages (from django-toolbelt)
Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /usr/local/lib/python3.2/site-packages (from django-toolbelt)
Requirement already satisfied (use --upgrade to upgrade): gunicorn in /usr/local/lib/python3.2/site-packages (from django-toolbelt)
Requirement already satisfied (use --upgrade to upgrade): dj-database-url in /usr/local/lib/python3.2/site-packages (from django-toolbelt)
Requirement already satisfied (use --upgrade to upgrade): dj-static in /usr/local/lib/python3.2/site-packages (from django-toolbelt)
Requirement already satisfied (use --upgrade to upgrade): static in /usr/local/lib/python3.2/site-packages (from dj-static->django-toolbelt)
Requirement already satisfied (use --upgrade to upgrade): wsgiref in /usr/local/lib/python3.2 (from static->dj-static->django-toolbelt)
Cleaning up...

看起来不错。需要为 Python 3.2 更新 static.py 文件。

【讨论】:

    猜你喜欢
    • 2015-07-28
    • 2012-11-20
    • 2016-09-29
    • 2016-08-02
    • 2016-02-27
    • 2013-10-19
    • 2014-02-06
    • 2014-01-03
    • 2012-10-11
    相关资源
    最近更新 更多