Instapy: Firefox on RP 3

Created on 5 Feb 2018  路  6Comments  路  Source: timgrossmann/InstaPy

I want to migrate my script to a Raspberry PI 3, Model B.

The script works well on my iMac using Chrome. I'd like to be more power efficient and not have to have the Mac on at night.

For the Pi, I need FF sadly:

session = InstaPy(username=insta_username,
password=insta_password,
use_firefox=True,
page_delay=25,
nogui=True)

Works on the iMac.

On the Pi the same script throws an error:

Traceback (most recent call last):
File "main-script-FF.py", line 20, in job
page_delay=25)
File "/home/pi/Projects/InstaPy-main-script/instapy/instapy.py", line 134, in __init__
self.set_selenium_local_session()
File "/home/pi/Projects/InstaPy-main-script/instapy/instapy.py", line 195, in set_selenium_local_session
self.browser = webdriver.Firefox(firefox_profile=firefox_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
self.binary, timeout)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 99, in _wait_until_connectable
"The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main-script-FF.py", line 98, in
schedule.run_pending()
File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 493, in run_pending
default_scheduler.run_pending()
File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 78, in run_pending
self._run_job(job)
File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 131, in _run_job
ret = job.run()
File "/usr/local/lib/python3.5/dist-packages/schedule/__init__.py", line 411, in run
ret = self.job_func()
File "main-script-FF.py", line 67, in job
session.end()
UnboundLocalError: local variable 'session' referenced before assignment

Ideas?

wontfix

Most helpful comment

FYI I've updated my ansible playbooks to use @ganeshkrishnan1 method for using chrome. You can do this manually by doing the following:

first change to root user

sudo su
echo "deb http://security.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list
apt-get update
apt-get install chromium-browser
apt-get install chromedriver
mv /usr/bin/chromedriver /path/to/InstaPy/assets/chromedriver

That's it! This works for me running headless on an RPi 3.

All 6 comments

I don't know your error but I'm using firefox-esr on my RP and on my Banana Pi R2

Check out #1345 That should get you going in the right direction.

I got chromium on Pi 3 working. Download the latest chrome driver, latest chromium (>62) from debian (not ubuntu) and install both. As long as chromedriver is in path, it works perfectly fine.

I had many issues with firefox the latest being elements overlapping and selenium aborting because of that.

FYI I've updated my ansible playbooks to use @ganeshkrishnan1 method for using chrome. You can do this manually by doing the following:

first change to root user

sudo su
echo "deb http://security.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list
apt-get update
apt-get install chromium-browser
apt-get install chromedriver
mv /usr/bin/chromedriver /path/to/InstaPy/assets/chromedriver

That's it! This works for me running headless on an RPi 3.

Marto32, your recipe worked for me too. I followed your steps exactly and have a session running on my raspberry pi 3 on the command line in headless mode as I type this.

Thank you! I can finally shut the iMac down. Mother Nature thanks you too :)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this problem still occurs, please open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

tibor picture tibor  路  3Comments

n0sw34r picture n0sw34r  路  3Comments

v77v picture v77v  路  3Comments

converge picture converge  路  3Comments