New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tree drawing doesn't work on a headless server #1887
Comments
|
This is also an issue for running anything that might draw a tree through CI systems; e.g. I test my notebooks for a project on travis and was hitting it. The super hacky workaround I came up with for this scenario, where it's not really crucial that the tree get drawn, is at: rawlins/lambda-notebook@7f151a0 Edit: true to form, I figured out what I was missing within 30 seconds of posting here, so there's a slightly better (but still hacky) thing at the link above, vs. what I originally posted. |
I managed to find a workaround for my configuration (Ubuntu 14 headless server), by installing python3-tk and xvfb and running jupyter notebook with xvfb-run.
I used the following code to test (note that tree.draw() will hang, as it is interactive):
|
I guess I never came back and posted in this issue, but I later ended up writing a pure python svg-based tree drawing package that works with nltk, and as a side-effect of being python-only also solves the problem of headless servers: https://github.com/rawlins/svgling For Jupyter in particular, you will also need to fully disable nltk png-based trees, since Jupyter runs all available reprs in the background even though it shows only one; there's a snippet on that page showing how. |
The |
This is more or less resolved by #2875 right? (If someone still wanted raster images in a headless setting, there's also now a straightforward conversion path to png via |
I don't use nltk anymore, but for what it's worth, I agree. My original problem would have been solved by svgling. |
nltk.tree.Tree
uses the Tcl (tkinter) backend to draw trees. Unfortunately, that doesn't seem to work on a headless server, which is the setup I use: run Jupyter on the server and access it via the browser from another machine.If
python3-tk
is not installed, I getIf it is, I get
However,
dot
works in such a setup, so it would be preferable if it was used as the backend instead of tk. Also, it could be used to implement_repr_svg_()
onTree
, which would also be a very welcome addition, as svg is a much better format for these kinds of things than png.The text was updated successfully, but these errors were encountered: