dataframe_image icon indicating copy to clipboard operation
dataframe_image copied to clipboard

Saving styled table as png files, outside of notebook

Open gregbert42 opened this issue 4 years ago • 4 comments

I am trying a simple export on a headless machine, at shell. The following gives me an error that it is trying to connect to my X11 server. Of course, the issue is that I am at a command prompt ssh'd in. Presumably it is trying to use chome. If that is the issue, is there a way to get it to use matplotlib like you can when you export entire notebooks?

(styled template derived from dataframe) import dataframe_image as dfi dfi.export(styled_table,'test_file.png')

gregbert42 avatar Sep 18 '20 08:09 gregbert42

Are you using docker? You can install chrome in docker

# Set up the Chrome PPA
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list

# Update the package list and install chrome
RUN apt-get update -y
RUN apt-get install -y google-chrome-stable

# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_VERSION 2.19
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR

# Download and install Chromedriver
RUN wget -q --continue -P $CHROMEDRIVER_DIR "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR

# Put Chromedriver into the PATH
ENV PATH $CHROMEDRIVER_DIR:$PATH
# update config to not run as root
RUN sed -i 's|exec -a "$0" "$HERE/chrome" "$@"|exec -a "$0" "$HERE/chrome" "$@" --no-sandbox --user-data-dir |g' /opt/google/chrome/google-chrome

mike-seekwell avatar Nov 07 '20 14:11 mike-seekwell

you could also just use matplotlib

dfi.export(df, 'dataframe_image.png', fontsize=16, table_conversion='matplot')

mike-seekwell avatar Nov 07 '20 14:11 mike-seekwell

with dfi, i am sure i there is a simple solution, but i get this error:

FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

i pip installed lxml, but that didnt seem to address it.

gregbert42 avatar Nov 07 '20 15:11 gregbert42

hmmm, are you sure you installed it into the right env? you could also try:

pip install html5lib

mike-seekwell avatar Nov 07 '20 15:11 mike-seekwell