So I have been trying to use webbrowser.get
from within my Docker container but it is failing to find a browser to launch.
I believe there are two ways to do this:
So far I've been trying to go with the ladder because I think its more full-proof when handing my Dockerfile over to others.
This is what I have so far but it continues not to find the browser:
# set base image (host OS)
FROM python:3.8
ENV CHROME_VERSION "google-chrome-stable"
RUN sed -i -- 's&deb http://deb.debian.org/debian jessie-updates main&#deb http://deb.debian.org/debian jessie-updates main&g' /etc/apt/sources.list \
&& apt-get update && apt-get install wget -y
ENV CHROME_VERSION "google-chrome-stable"
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list \
&& apt-get update && apt-get -qqy install ${CHROME_VERSION:-google-chrome-stable}
RUN set -eux \
; . /root/.bashrc
Then I just try running docker exec -it [container id] python
and running the code import webbrowser; webbrowser.get('http://google.com')
import webbrowser; webbrowser.get('http://google.com')
but it just continues to return False
and not open a browser.
Any help would be greatly appreciated.
Have you tried webbrowser.get()
to get the browser, or even simply webbrowser.open("http://example.com")
to use the default browser? If that still won't work, that would be a different question anyway. Your current usage messed up with the 2 different APIs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.