I took a lot of trial and error, so I'll just upload the results. When I installed the latest version of chromedriver-binary
, the major version was larger than google-chrome-stable
and I got an error. It seems that you can use something other than stable
on the Chrome side, but I decided to match chromedriver-binary
with Chrome.
Dockerfile
FROM python
#Chrome installation
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add && \
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list && \
apt update && apt install -y google-chrome-stable
WORKDIR /python
COPY requirements.txt .
# chromedriver-Match major version of binary to Chrome
# google-chrome --version: "Google Chrome 0.0.0.0"Returns a string like
# grep --only-matching: (In each line)Returns all the matched parts in order
# head -n 1:Get only the major version
# sed --in-place:I do not know
RUN sed -e s/chromedriver-binary/chromedriver-binary==`google-chrome --version | grep -o -E "[0-9]*" | head -n 1`.*/ -i requirements.txt
RUN pip install --upgrade pip && pip install -r requirements.txt
requirements.txt
altair
altair_saver
chromedriver-binary
jupyter
matplotlib
numpy
pandas
scipy==1.5
selenium
The titles should be ʻaltair, ʻaltair_saver
, chromedriver-binary
, selenium
.
main.py
import altair
import chromedriver_binary #PATH is passed by import;Not used as a module
altair.renderers.enable('altair_saver') #There was an argument to specify the format in the official document, but I removed it because I was angry
altair.Chart(...).....save('plot.png') #Successful
Recommended Posts