pip install django-graphos 不兼容 python 3

pip install django-graphos is not python 3 compatible

我最近在 github issues page for django-graphos 上发布了以下问题,但我认为它不会定期维护,因此我预计不会很快得到解决。我正在开发一个 heroku/django 构建,我正在使用 OSX 10.9.5 上的 python 3.5 在 vi​​rtualenv 中进行测试。我喜欢 django-graphos 的外观,因为它足够轻巧且不依赖,因此它似乎非常适合 Heroku 上的小型数据库支持的统计图形。因此,当我尝试从 venv 安装却失败时,我感到很沮丧。

错误如下:

(venv) $ > pip install django-graphos
Collecting django-graphos
  Using cached django-graphos-0.1.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/qt/s4gp855d38s6rrj34fdlmwk40000gn/T/pip-build-q69jbvga/django-graphos/setup.py", line 132, in <module>
        package_data=find_package_data("graphos", only_in_packages=False),
      File "/private/var/folders/qt/s4gp855d38s6rrj34fdlmwk40000gn/T/pip-build-q69jbvga/django-graphos/setup.py", line 106, in find_package_data
        print >> sys.stderr, (
    TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/qt/s4gp855d38s6rrj34fdlmwk40000gn/T/pip-build-10_yhb6j/django-graphos/

正如 @Tadhg McDonald-Jensen 指出的那样,这个错误源于 python 2 print 函数调用,令人恼火的是,它有一个相当简单的建议修复 proposed as a branch merge on github 但它还没有被 master 接受。

更新:

@Tadhg McDonald-Jensen 提出的解决方案对我有用,也就是说我能够克隆项目,对有问题的 print >> x 调用进行必要的编辑并将分支拉到掌握。我对 pip install git+<source> 进行必要编辑的项目克隆是 here。然而,正如@Evert 指出的那样,pip install django-graphos-3 也是一种解决方案,这可以解释为什么 django-graphos 已经休眠了六个月。我希望这能像帮助我一样帮助其他人。

请注意不再需要手动编辑,只需


不幸的是,库(在发布这篇文章的最初时间)似乎不太兼容 vs3,您可以从 github 下载源代码,对 setup.py 进行以下更改:

line 83-85
-    print >> sys.stderr, (
-            "Directory %s ignored by pattern %s"
-            % (fn, pattern))
+    print("Directory %s ignored by pattern %s" % (fn, pattern),
+          file = sys.stderr)

line 106-108
-    print >> sys.stderr, (
-        "File %s ignored by pattern %s"
-        % (fn, pattern))
+    print("File %s ignored by pattern %s" % (fn, pattern),
+          file = sys.stderr)

然后在您的终端中,您可以使用 python setup.py install 获得与使用 pip 相同的结果。

我用 pip 搜索了 django-graphos,弹出了以下包:

django-graphos-3 (0.1.1) - Django app to provide a JS agnostic way to work with charts for Python 3+

我没试过,但你可能用

解决了你的问题
pip install django-graphos-3

请注意,这似乎只是一个带有一些 Python 3 个修复的分支,仅此而已。就像原来的包一样,这里的开发已经停止了。 实际的 Python 3 更新并不像您链接到的 PR 那样完整,因为它们不包括演示项目,但这不应该妨碍安装。这些修复基本上是由 Tadhg 的回答给出的。

我们更新了 setup.py 以使其与 Python 兼容 3. 还将其推送到 pypi。现在 pip install django-graphos 应该可以与 python3 一起使用了。

https://pypi.python.org/pypi/django-graphos/0.1.2