0

So I'm trying to deploy on heroku my app that uses node.js and python. it works on my computer but when i try to run it on heroku i get an error:

    from selenium import webdriver
ImportError: no module named selenium

I have added Chrome, chromedriver, and selenium as buildpacks and in my Procfile i even have:

worker: pip install selenium
worker: python scraper.py

I am current just trying to get my python to work as i have already confirmed my javascript works.

2 Answers 2

2

The best way i found after along search over the internet, is using PhantomJs() web driver from selenium

from selenium import webdriver
driver = webdriver.PhantomJS()

#your code here

driver.quit()

and then use this buildpackge https://github.com/stomita/heroku-buildpack-phantomjs

$ heroku create --stack cedar --buildpack https://github.com/stomita/heroku-buildpack-phantomjs.git

# or if your app is already created:
$ heroku buildpacks:add https://github.com/stomita/heroku-buildpack-phantomjs

$ git push heroku master

and it shall work for you :)

Sign up to request clarification or add additional context in comments.

Comments

1

module dependencies don't go in the procfile, they go in the requirement.txt file on the root of your project.

When you deploy on Heroku, you should see the log of the modules that were installed.

Also, you probably don't want to use Chromedriver unless you're running Chrome Headless on Heroku, because Heroku cannot open a browser on the server: it has no graphic interface.

You might want to use something like PhantomJS or Chrome Headless to make this work.

1 Comment

I have it in the requirements.txt I took it out of Procfile but I think I'm just going to rewrite it to be more compatible with heroku. :/ Also I am running it headless. The only issue is that selenium can't be installed for use in python on heroku.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.