jeroenjanssens / data-science-at-the-command-line

Data Science at the Command Line
https://datascienceatthecommandline.com
Other
3.77k stars 766 forks source link

Ch05 "display" not working on Ubuntu 20.04 LTS | Optional Solution #127

Open MaximilianSoerenPollak opened 2 years ago

MaximilianSoerenPollak commented 2 years ago

In Chapter 5 where the rush plot is created and subsequently displayed, on my ubuntu machine (20.04 LTS) this is causing an issue. Line in question:

$ rush plot -x value -y count --geom col --height 2 fb.csv > fb.png
$ display fb.png

The Issue is that the command line tool "display" is not by default installed, and when installed via sudo apt install imagemagick it still needs an X window server to function, which I could not get running on my ubuntu machine.

I have however found a different command line tool, that does the job although a bit more rudimentary.

It's called "caca" and can be installed by doing this. sudo apt-get install caca-utils !Note, please do this in the terminal where the docker is active, and then restart the docker container, so it has access to it.

After you have done this, you can then go ahead and open any image with cacaview /PATH/TO/image.jpg (make sure the terminal is big enough)

The other option you have is to display it in-line with the other command line tool: img2txt img2txt fb.png

This will display the image inside the terminal without opening up an "in terminal window".

Original Image Original Image

Img2txt img2txt Render

I hope this helps somebody out who was stuck there like my, maybe in future revisions there can be a note that "display" does not work on Ubuntu (out of the box) and either how to fix that, or what else to use.

kurokirasama commented 3 weeks ago

Just note that to date, this still isn't fixed. How to open the image within the docker container?