Problem with deploying my python script using Selenium

I m trying to deploy my webpage but while i cannot figure out how i manage the buildpacks from heroku if i want to deploy my page here.
Here is the code i used: chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = os.environ.get(“GOOGLE_CHROME_BIN”)
service = ChromeService(executable_path=os.environ.get(“CHROMEDRIVER_PATH”))
driver = webdriver.Chrome(service=service, options=chrome_options)
# Navigate to the webpage
Also about the environment variables for google chrome and chromedriver, should i put the path that they exist in my local environment?

Hi there,

You most likely used the Chrome buildpack on Heroku to add Chrome to Heroku’s stack image. You will need to do something similar on Render by adding a build script something like this one: If you add Chrome to the path, you should need to use the environment variables.

You will need to include a similar thing for the Chrome Driver. To find the locations of Chrome Driver downloads, look here:


Render Support, UTC+10 :australia:

I got this working (Django+Celery).

For the last 6 months or so, selenium automatically locates and sets up the driver automatically, you don’t need to download or setup anything in the code (for the Webdriver).

You just need to make sure your Render VM has chrome installed and in the PATH

I have a build script for my worker VM:

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


if [[ ! -d $STORAGE_DIR/chrome ]]; then
  echo "...Downloading Chrome"
  mkdir -p $STORAGE_DIR/chrome
  cd $STORAGE_DIR/chrome
  wget -P ./
  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
  echo "...Using Chrome from cache"

pip install -r requirements.txt

Then my python code:

options = webdriver.ChromeOptions()

    driver = webdriver.Chrome(options=options)


    min_exchange_rate = 1.3
    max_exchange_rate = 1.4

    element = driver.find_element(by=By.XPATH, value='//*[@id="__next"]/div[3]/div[2]/section/div[2]/div/main/div/div[2]/div[1]/p[2]')

    exchange_rate = float(element.text.split(' ')[0])

    driver.quit()  # maybe close instead?

Hello Mowbray.
I would love to have some more infos, if you could.
How do you set up your enviroments on settings?
Don’t you need to import those on your code?
How do you start your .sh file?


Hey Luan Paganucci,

The only environment setting that needs to be made is adding the chrome binary to the $PATH. You don’t have to do anything special in the code, you can just import and use selenium.

My worker VM (I put it in the root of my git repo).

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

# add Chrome's location to the PATH as part of your Start Command
export PATH="/opt/render/project/.render/chrome/opt/google/chrome:$PATH"
echo "Current PATH: $PATH"

celery -A mydjangoproject worker --beat --scheduler django --loglevel=info --concurrency 4

To tell Render to run this script, you can either use the render.yaml or the web interface for the VM.

  - type: worker
    name: mice-prod-worker
    region: ohio
    env: python
    buildCommand: "./"
    startCommand: "./"
1 Like

Thank you for your help.
I’ve been able to run now. Just adjusting some ishues that i believe it’s in the options.

Thank you again!

1 Like

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