Driver path is None but file location can be found

Question:

I have a web scraper that uses Undetected Chromedriver & WebDriverManager to download & automate a Chromium webdriver.

On Windows I initialize the Undetcted Chromedriver instance by passing the executable_path to the output of ChromeDriverManager().install(). This works fine.

Now I am trying to Dockerize my application, however I am getting:

Error: expected str, bytes or os.PathLike object, not NoneType

when trying to initialize my object as lined out below. I’m not getting any other context to where the error is being raised from.

Driver initialisation

options = uc.ChromeOptions()
path = ChromeDriverManager(os_type="linux64").install()
driver = uc.Chrome(
    options=options, executable_path=path, force=True
)

I’ve also tried:

  1. Check if the file at the path ChromeDriverManager.install() returns exists using os.path.isfile() which returned True
  2. Pass a relative path to executable_path.
Asked By: victorbrnk

||

Answers:

I don’t quite know where it went wrong on my first Docker container but here’s how I fixed it:

It seems like the ChromeDriver wasn’t being downloaded properly. I’m guessing something to do with $_PATH variables.

I installed the Chromedriver through docker by adding this to the Dockerfile

RUN wget -q "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
RUN apt install -y ./google-chrome-stable_current_amd64.deb

RUN wget -q "https://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip" -O /tmp/chromedriver.zip 
    && unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/ 
    && rm /tmp/chromedriver.zip 
    && chmod +x /usr/local/bin/chromedriver

Which works great

Answered By: victorbrnk