2

I am trying to run through the d3py example code available in the d3py readme file (see link below), and am receiving the following error:

https://github.com/mikedewar/d3py/blob/master/README.md

(python 2.7.3 on 32-bit Windows)

>>> # instantiate the figure object
>>> fig = d3py.Figure(df, name="basic_example", width=300, height=300) 
        Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "build\bdist.win32\egg\d3py\d3py.py", line 97, in __init__
    IOError: [Errno 2] No such file or directory: 'static/d3.js'
>>>

I installed the d3py package by using the following command in PowerShell:

easy_install https://github.com/mikedewar/d3py/tarball/master

and, importing the package within a python session (i.e. import d3py) does not result in any errors. What can I do to make the example code work?

VividD
  • 10,456
  • 6
  • 64
  • 111
baha-kev
  • 3,029
  • 9
  • 33
  • 31
  • I also tried the example code above on OS X, and it gives the same error -- no `static/d3.js` file. – baha-kev Dec 05 '12 at 18:59

1 Answers1

4

So d3py is a really raw project, and to be honest our setup.py sucks quite hard. This means you either need to make a pull request with some fixes to setup.py or you need to make a folder called static in your project folder and make sure that d3.js is inside the folder.

On the assumption that the second option is the one you'll use, just to make it clear:

In a terminal, change to the directory that holds your project, like

cd ~/Desktop/my/awesome/project

Make a folder called static:

mkdir static

then move into that directory and get the d3.js file from the repo:

cd static
curl -O https://raw.github.com/mikedewar/d3py/static/d3.js

Apologies for this terrible hack! d3 based plotting from inside python is definitely going to happen, but maybe not with this project!

Having said that, d3py will work as advertised once you get it to run! A really popular use case of d3py, which we hadn't quite realised would be popular, is that people use it to quickly mock up some javascript, using the output of d3py as a starting point for fancier visualisations.

slayton
  • 20,123
  • 10
  • 60
  • 89
Mike Dewar
  • 10,945
  • 14
  • 49
  • 65
  • Very cool -- thank you! FYI - You also have to download another file (same folder) called d3py_template.html: `curl -O https://raw.github.com/mikedewar/d3py/static/d3py_template.html` – baha-kev Dec 05 '12 at 21:20
  • BTW -- that's exactly what I am thinking about using d3py for: to do the bulk of the Javascript/D3 coding so that I only need to do minor tweaks to a visualization. Thanks again for putting this package together. – baha-kev Dec 05 '12 at 21:23
  • Hi! Just in case anyone ends up here looking around at d3py. I made d3py a couple of years ago now to see what it would feel like to plot d3 graphics from Python. It was fun! But I didn't have the time to do it properly, which was a shame. However, Rob Story did! He made vincent, which is available at https://github.com/wrobstory/vincent. It's a much better implementation, and is much better thought out. Please do check it out! – Mike Dewar Mar 15 '14 at 20:58