Receiving this error in a Docker and Python3.10 Container
An example link is as follow: https://finance.yahoo.com/quote/BABA/options?p=BABA&date=1653004800
Browser closed unexpectedly:
Here is my Dockerfile
FROM python:3.10
RUN apt-get update
# TA-Lib
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz &&
tar -xvzf ta-lib-0.4.0-src.tar.gz &&
cd ta-lib/ &&
./configure &&
make &&
make install &&
cd .. &&
rm -R ta-lib ta-lib-0.4.0-src.tar.gz
COPY requirements.txt /tmp/
COPY data/stocks.csv /tmp/data/stocks.csv
RUN pip install --requirement /tmp/requirements.txt
RUN pip freeze >> /tmp/requirement.txt
RUN pyppeteer-install
CMD ["python", "/tmp/app.py"]
async def async_get_options_chain(ticker, date=None, raw=True, headers={'User-agent': 'Mozilla/5.0'}):
"""Extracts call / put option tables for input ticker and expiration date. If
no date is input, the default result will be the earliest expiring
option chain from the current date.
@param: ticker
@param: date"""
site = options.build_options_url(ticker, date)
browser = await launch({'headless': True, 'options': {'args': ['--no-sandbox', '--disable-setuid-sandbox']}})
page = await browser.newPage()
await page.goto(site)
content = await page.evaluate('document.body.textContent', force_expr=True)
2
Answers
What appears to have solved this issue was not installing it from packages but rather from the Dockerfile. Now I have to solve a timeout issue instead :)
Dockerfile
Python
I had the same problem and what solved it for me was indeed the docker file not having the correct requirements, but also, when I built the Docker, I needed to add
--platform=linux/amd64
. I’m running on an MB 16" M1 chip.This solved it for me.
Docker file
And when I build the Docker, I add
--platform=linux/amd64
like