Can't find Chrome Binary

Thought I should start a new topic since I wasn’t getting any response after my first problem was fixed here: Getting Chrome in PATH

My web service was able to find Chrome, but now I’m getting the error:
Message: unknown error: cannot find Chrome binary

I tried fixing it by adding the line: chrome_options.binary_location = "/opt/render/project/.render/chrome/opt/google/chrome/"
before the service variable, but that just gave me the error:
unknown error: no chrome binary at /opt/render/project/.render/chrome/opt/google/chrome/

I’ve searched all over the internet, but all the solutions I’ve found either don’t work, or are meant for local hosting. Any help appreciated!

2 Likes

Hi,

You haven’t said which library you’re using to require Chrome.

If you’re using Puppeteer, a post like this one may help

If you’re doing something more manual, maybe a this post may be better suited

Essentially, you need to install Chrome at build time to a path that is carried over from build to the running instance (somewhere in /opt/render/project/)

Alan

1 Like

Sorry about that. I’m using Selenium in Python.

The second link you posted is the one I followed to get me this far. I was able to get chrome in PATH (the error I was getting before was “Chrome not in PATH”) using the export command at build time, but now it’s telling me it can’t find the chrome binary. I’m not sure I’m uploading the right files either. I only uploaded chromedriver.exe into my root program folder.

this is my code:

chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--force-dark-mode")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-infobars")
capabilities = { "resolution": "768X432" }

service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(executable_path="opt/render/project/chromedriver", desired_capabilities=capabilities,options=chrome_options,service=service)

and this is error that occurs between the service and driver variables:
Feb 14 11:28:32 AM Message: unknown error: Chrome failed to start: exited abnormally. Feb 14 11:28:32 AM (unknown error: DevToolsActivePort file doesn't exist)
Feb 14 11:28:32 AM (The process started from chrome location /opt/render/project/ is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

2 Likes

Meant to say export command at START time.

1 Like

Did you figure out where CHROMEDRIVER_PATH and GOOGLE_CHROME_PATH are installed? The following, respectively, are not correct.

/opt/render/project/.render/chrome/opt/google/chrome/bin/chromedriver
/opt/render/project/.render/chrome/opt/google/chrome/bin/google-chrome

1 Like

Let’s take a step back: Are you installing the Chrome & Chromedriver binaries explicitly as part of your Build Command?

We’re going to need some details here, what you’re trying, what you’re installing, and what output you’re getting.

If you don’t want to share these details on the community forum, please feel free to raise a ticket from the “Contact Support” link at the bottom of the Dashboard.

Alan

1 Like

I am not installing Chrome & Chromedriver binaries as part of my Build command. I was told when I was getting the error that Chrome wasn’t in PATH that this code:
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(executable_path="opt/render/project/chromedriver", desired_capabilities=capabilities,options=chrome_options,service=service)

took care of that. I’m not sure though. I would rather install them as part of the Build Command, so that they aren’t wasting time installing every time I start the service, but I’m not sure how to do that. Chromedriver.exe and Chrome.exe are in the root directory, but I’m not sure how to install binaries.

1 Like

Render Native Environments don’t have Chrome installed by default, so you’ll need to install it yourself. I linked to a post with an example of that in my first reply.

Your .exe files are probably for Windows. Render environments are Linux.

If you’re using something like pyppeteer, then that can also install Chrome, if you look at the pyppeteer docs, you could try to install manually at the build step, maybe something like:

pip install -r requirements.txt && pyppeteer-install

You would also need to refer to their docs to ensure it’s installed an a path that is taken from build to runtime, as per puppeteer, which I also linekd to a post in my first reply.

Alan

1 Like

Dear Alan,

Thank you for your advices and recommendation. I’m also having the same problem as well using Python, Selenium, ChromeDriver on Render web service

Logs response:
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

My case is that basically if I run the same set of script in my local device, the function is working well normally. However, this problem comes up when trying to run it after having deployed on render successfully.

service = Service(ChromeDriverManager().install())

Although I have used Chromedriver manager in the built already, I’d like to ask two questions.

  1. Will render automatically detect the path from chromedriver manager installation and use it when scripts running? Or I need to tell render the path in the script? If so, what path I can use
  2. As I can run the script smoothly in local, does Chrome binary imply I need to install Chrome browser additionally on render cloud web service? I try to add chrome linux file in my root directory, but it seems not working yet.

Appreciate if you could share some thoughts if things are doable.

Looking forward to hearing from you, thank you!!

Hi,

The questions you’ve raised have been covered above.

There will always be differences between environments development mode/Local, production mode/Render, etc. These differences need to be considered and configured as required for your own app in each environment. Every app is different, their purpose, style & implementation can vary wildly so we’re unable to provide general debugging help as you’re the one that will know your app best.

In summary:

  • Chrome is not available by default on Render Native Environments. You’ll either need to install it as part of the Build Command, or create your own environment with the packages you need in Docker.

  • If installing it on a Native Environment, you can use whichever means you want.
    A basic example build script gist is linked in one of the posts linked above.
    Some packages have Chrome installers built in, like Puppeteer on Node and Pyppeteer on Python, also referenced above.
    You’ll want to configure Chrome to be installed somewhere within the /opt/render/project path at Build time, so that it’s available at runtime. You’ll also need to configure whichever packages require Chrome to the install path you choose.

Alan

1 Like

I’m still getting the error that the chrome-binary cannot be found.

This is my build command (most of it copied from the gist you shared):

#!/usr/bin/env bash
# exit on error
set -o errexit

STORAGE_DIR=/opt/render/project/.render

if [[ ! -d $STORAGE_DIR/chrome ]]; then
echo "...Downloading Chrome"
mkdir -p $STORAGE_DIR/chrome
cd $STORAGE_DIR/chrome
wget -P ./ https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt-get install -y libglib2.0-0=2.50.3-2 \
libnss3=2:3.26.2-1.1+deb9u1 \
libgconf-2-4=3.2.6-4+b1 \
libfontconfig1=2.11.0-6.7+b1 \
chromium-browser
sudo dpkg -x ./google-chrome-stable_current_amd64.deb $STORAGE_DIR/chrome
rm ./google-chrome-stable_current_amd64.deb
cd $HOME/project/src # Make sure we return to where we were
else
echo "...Using Chrome from cache"
fi

pip install --upgrade pip
pip install -r requirements.txt``

and this is the part of my script that runs selenium:

        chrome_options = Options()
        chrome_options.add_argument("--no-sandbox")
        chrome_options.add_argument("--headless")
        chrome_options.add_argument("--disable-dev-shm-usage")
        chrome_options.add_argument("--force-dark-mode")
        chrome_options.add_argument("--start-maximized")
        chrome_options.add_argument("--disable-gpu")
        chrome_options.add_argument("--disable-extensions")
        chrome_options.add_argument("--disable-infobars")

        print('options defined')
        capabilities = {
            # "resolution": "2560X1440"
            # "resolution": "1280X720"
            "resolution": "768X432"
        }
        
        driver = webdriver.Chrome(executable_path="/opt/render/project/.render/chrome/opt/google/chrome/google-chrome/chromedriver",
                                   desired_capabilities=capabilities,options=chrome_options)
        print('Setup selenium complete')
        return driver

this is my start command:
export PATH="${PATH}:/opt/render/project/.render/chrome/opt/google/chrome/google-chrome/chromedriver"; gunicorn app:app

Not sure where I’m going wrong.

apt-get and sudo are not available on Render Native environments. If you have further custom OS-level package requirements you’ll need to use Docker.

Alan

I removed the apt-get and sudo commands (I only put them in because I came across a stackoverflow post that suggested if the chrome binary couldn’t be found I might need to add some files):

here’s my build command:

#!/usr/bin/env bash
#exit on error
set -o errexit

STORAGE_DIR=/opt/render/project/.render
if [[ ! -d $STORAGE_DIR/chrome ]]; then
echo “…Downloading Chrome”
mkdir -p $STORAGE_DIR/chrome
cd $STORAGE_DIR/chrome
wget -P ./ https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -x ./google-chrome-stable_current_amd64.deb $STORAGE_DIR/chrome
rm ./google-chrome-stable_current_amd64.deb
cd $HOME/project/src # Make sure we return to where we were
else
echo “…Using Chrome from cache”
fi

pip install --upgrade pip
pip install -r requirements.txt

here’s the part of my code that runs selenium:

def setup():
print('—>Setup selenium start : ’ + str(datetime.now()))
chrome_options = Options()
chrome_options.add_argument(“–no-sandbox”)
chrome_options.add_argument(“–headless”)
chrome_options.add_argument(“–disable-dev-shm-usage”)
chrome_options.add_argument(“–force-dark-mode”)
chrome_options.add_argument(“–start-maximized”)
chrome_options.add_argument(“–disable-gpu”)
chrome_options.add_argument(“–disable-extensions”)
chrome_options.add_argument(“–disable-infobars”)

       print('options defined')
       capabilities = {
          # "resolution": "2560X1440"
          # "resolution": "1280X720"
           "resolution": "768X432"
       }

       driver = webdriver.Chrome(desired_capabilities=capabilities,options=chrome_options)
       #,service=service
       print('Setup selenium complete')
       return driver

and here is my start command:

export PATH=“${PATH}:/opt/render/project/.render/chrome/opt/google/chrome/google-chrome/chromedriver”; gunicorn app:app

Still getting the same error. What am I doing wrong?

Hi Alan,

Thank you for the prompt response, appreciate it!

I tried to run Pyppeteer which the app was deployed successfully. However, render log respond this message to me, although the app can work in my local machine. any thoughts?

Feb 22 06:07:09 PM PermissionError: [Errno 13] Permission denied: ‘/opt/render/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome’

Looking forward to hearing from you! Thank you!

These are 2 different conversations, and this post is getting extremely confused.

idylljokesmith - The script in the gist installs Chrome. You’ve changed the path export to reference “chromedriver”. That’s a different binary, you’d need to install that separately, there are Python packages that appear to help with that.

Yeyoyo, I mentioned Pyppeteer above, there’s an install command, and you’ll need to refer to their docs for more info.

Alan

1 Like

Hi Alan,

Thank you Alan! I’ve referred to your mentioned above regarding Pyppeteer install command and deployed successfully. Render log stills respond me this error. Likely Render rejects the web service app access to this render path when any functions use Pyppeteer (It’s weird), although it has been deployed successfully and other web app can work normally.

Feb 22 06:07:09 PM PermissionError: [Errno 13] Permission denied: ‘/opt/render/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome’

Any thoughts?

Looking forward to hearing from you! Thank you!

As mentioned in my first reply to this topic:

Essentially, you need to install Chrome at build time to a path that is carried over from build to the running instance (somewhere in /opt/render/project/)

You’ll likely need to set an alternative directory.

Alan

I’ve given up on trying to get this to work because I don’t understand enough. I’m trying the Docker route, but not fairing much better. Seems this might be beyond my capabilities at the moment. Not sure what to mark as a solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.