Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver patching gets stuck in Docker container #878

Open
PhilK-7 opened this issue Nov 8, 2022 · 5 comments
Open

Driver patching gets stuck in Docker container #878

PhilK-7 opened this issue Nov 8, 2022 · 5 comments

Comments

@PhilK-7
Copy link

PhilK-7 commented Nov 8, 2022

I'm executing a Python script inside a Docker container. So far, everything worked for me locally.

The call uc.Chrome() by default triggers the patcher that downloads the executable to a local path.

Now, in the container, I instead get the following stack trace:

2022-11-08 15:14:44,487 [INFO] patching driver executable /home/airflow/.local/share/undetected_chromedriver/chromedriver
Process Process-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/local/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/airflow/.local/lib/python3.10/site-packages/undetected_chromedriver/dprocess.py", line 59, in _start_detached
    p = Popen([executable, *args], stdin=PIPE, stdout=PIPE, stderr=PIPE, **kwargs)
  File "/usr/local/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.10/subprocess.py", line 1717, in _execute_child
    and os.path.dirname(executable)
  File "/usr/local/lib/python3.10/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

The program gets stuck at this point.

@emanodame
Copy link

How docker

@axiangcoding
Copy link

Same issue. how we install chromedriver locally?

@Arsh1219
Copy link

same issue, any solution?

@axiangcoding
Copy link

axiangcoding commented Mar 15, 2023

I found a way that works for me
Dockerfile

FROM python:3.11-alpine
WORKDIR /app
RUN apk update && apk upgrade
RUN apk add chromium chromium-chromedriver

COPY requirements.txt ./
RUN pip install -r requirements.txt

COPY main.py ./
ENTRYPOINT ["python", "-u", "main.py"]

inside main.py

options = uc.ChromeOptions()
options.add_argument("--disable-gpu")
options.add_argument('--no-sandbox')
driver = uc.Chrome(version_main=111, options=options, headless=True,
                   driver_executable_path="/usr/bin/chromedriver")

@grayskripko
Copy link

has relation to #747

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants