I'm trying to draw graph (inline) of nltk
inside of jupyter-notebook
. But got error:
TclError: no display name and no $DISPLAY environment variable
I have tried to set $DISPLAY
to different values:
$env DISPLAY=0.0
# or
$env DISPLAY=inline
# or
$env DISPLAY=
but got error (or similar):
TclError: couldn't connect to display "0.0"
here is my code https://github.com/hyzhak/nltk-experiments/blob/master/main.ipynb the last cell.
Environment: official anaconda3 docker -- continuumio/anaconda3:4.4.0
https://github.com/ContinuumIO/docker-images. With nltk==3.2.3
inside.
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
Type "copyright", "credits" or "license" for more information.
IPython 5.3.0 -- An enhanced Interactive Python.
How could I solve this error and inline nltk
graph inside of jupyter notebook
?
Update 1
http://www.nltk.org/_modules/nltk/draw/tree.html#draw_trees according to the sources of nltk tree draw it uses tkinter
.
Update 2
I have asked the same question in official nltk github repository https://github.com/nltk/nltk/issues/1765
Update 3
I think the reason of error could be the headless host (docker). I have installed xvfb
but seems it is note enough.
RUN apt-get install -y xvfb
Solution
I thought that xvfb
is launched by default but It should be run explicitly. So after I have launched it I could make screenshots of nltk tree graph.