1

I recently posted the following issue on the github issues page for django-graphos, but I don't think it is maintained that regularly and thus I'm not expecting a resolution anytime soon. I'm working on a heroku/django build that I'm testing in a virtualenv using python 3.5 on OSX 10.9.5. I like the look of django-graphos, as it's light and nondependent enough that it seems perfect for small-scale database-powered statistics graphing on Heroku. I was thus dismayed when I tried to install from the venv and had it fail on me.

The error is as follows:

(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/

As @Tadhg McDonald-Jensen points out, this error stems from a python 2 print function call which, annoyingly, has a fairly simple suggested fix proposed as a branch merge on github but it has not been accepted into master.

Update:

The solution as proposed by @Tadhg McDonald-Jensen worked for me, which is to say that I was able to clone the project, make the edit necessary to the problematic print >> x call and pull the branch to master. My clone of the project with edits necessary for pip install git+<source> to work are here. However as @Evert points out, pip install django-graphos-3 is also a solution, which may explain why django-graphos has been dormant for six months. I hope this helps someone else as much as it's helped me.

Ian
  • 172
  • 1
  • 13
  • that is syntax for python 2 print statement, it is not on your end since that is not valid python 3 code. – Tadhg McDonald-Jensen May 08 '16 at 19:51
  • I just tried it and got the exact same error, it seems it isn't supported for python 3 at the moment.... – Tadhg McDonald-Jensen May 08 '16 at 19:53
  • @TadhgMcDonald-Jensen Ah, good catch. Thank you for testing! I will update my issue post. – Ian May 08 '16 at 19:54
  • I don't know much about github but [this suggested change](https://github.com/agiliq/django-graphos/pull/32/commits/3eaed0463e570df8f51ad472e48ebc0a8a04356a) seems to be what is needed (As well as adding the `from __future__ import print_function`) – Tadhg McDonald-Jensen May 08 '16 at 20:00
  • @TadhgMcDonald-Jensen any tips on making the install of that commit without using pip? – Ian May 08 '16 at 20:15
  • 1
    Pip install a pull request: http://stackoverflow.com/questions/13561618/pip-how-to-install-a-git-pull-request/13561621 –  May 08 '16 at 20:39
  • If you don't want to use pip (but you tagged your question with `pip`), check out the PR as described [in the GitHub documentation](https://help.github.com/articles/checking-out-pull-requests-locally/), then run `setup.py`. –  May 08 '16 at 20:40
  • @Evert No this is exactly what I needed, thank you! – Ian May 08 '16 at 20:41
  • Let us know if it works; I've never done this for a PR, only for pip installing branches (which is similar though). –  May 08 '16 at 20:44
  • Note btw that the PR is half a year old; I assume it's still compatible with the current master code, but may not. If not, you'll have to manually edit some files as per Tadhg's answer. –  May 08 '16 at 20:45
  • @Evert Yeah, I don't know what their deal is...it shouldn't be that hard for the publisher to evaluate/accept the proposed merge, but alas. I will try it and let you know – Ian May 08 '16 at 20:53
  • From looking at the date of the last commit (Sep 2015), the project is more or less dead, or at least in hibernation. There might be more up-to-date forks of it, but that'll require some searching, and the original project will retain the `pip` package name. –  May 08 '16 at 21:49

3 Answers3

4

We have updated setup.py to make it compatible with Python 3. Also pushed it to pypi. Now pip install django-graphos should work with python3.

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

Akshar Raaj
  • 14,231
  • 7
  • 51
  • 45
3

I did a search with pip for django-graphos, and the following package popped up:

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

I haven't tried, but you probably solve your issue with

pip install django-graphos-3

Note that this appears to be simply a fork with some Python 3 fixes, and nothing more. Just as the original package, development here has stopped. The actual Python 3 updates are not as complete as the PR you've linked to, since they do not include the demo project, but that shouldn't hinder the installation. The fixes are essentially those given by Tadhg's answer.

  • Aha! I just finished pulling the branch to master in my own clone of the project, and the install worked (see comment on @Tadhg McDonald-Jensen's answer). I wonder if github offers a way to see the differences between two separate projects because I don't think there will be a ton of difference between mine and django-graphos-3. Thank you for your help! – Ian May 08 '16 at 22:02
  • I've selected @Tadhg's answer as correct because that was what I ended up doing, but upvotes all around. Thank you again. – Ian May 08 '16 at 22:03
2

Note this manual edit is no longer necessary, simply using pip3 install django-graphos should work


Unfortunately it seems that library (at the original time of this posting) is not quite properly vs3 compatible, you can download the source from github, make the following changes to the 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)

Then in your terminal you can use python setup.py install to get the same result as using pip.

Community
  • 1
  • 1
Tadhg McDonald-Jensen
  • 20,699
  • 5
  • 35
  • 59
  • I'm not familiar with github either, and I'm wondering if I can just download the commit that contains the python 3 compatibility changes... – Ian May 08 '16 at 20:27
  • I realized that that commit only changes one of these places but there are two places where the old `print` syntax is used, you are probably better to make the edits yourself. – Tadhg McDonald-Jensen May 08 '16 at 20:45
  • This worked. I have successfully cloned [this github project](https://github.com/nanuxbe/django-graphos) to [my own](https://github.com/iannesbitt/django-graphos), then made the necessary changes in nanuxbe's python 3 compatibility branch and merged to master. I have verified that the install works with the command `pip install git+https://github.com/iannesbitt/django-graphos.git` and now I suppose we'll see what the underlying functionality is like... – Ian May 08 '16 at 21:59