Skip to content

Latest commit

 

History

History
112 lines (81 loc) · 5.48 KB

How_to_Raspberry.md

File metadata and controls

112 lines (81 loc) · 5.48 KB

How to run InstaPy on a RaspberryPi with Python 2.7 & Python 3

NOTE: If you add an empty file named ssh to the boot directory, ssh will be enabled when you first start your RPi (more info on the official website - section 3 - here). If you do this, you can connect your RPi via ethernet, ssh in (once you have your ip) and skip right to the update step below (step 7). If you do not want to do this, follow the initial setup instructions to connect peripherals below.

  1. connect rpi3 to monitor via HDMI
  2. connect internet via cat5
  3. insert usb for wireless keyboard and mouse (if using)
  4. plug in rpi3 with sd card preloaded with NOOBs
  5. select country & install Raspbian
  6. open terminal --> sudo raspi-config -->interfacing options --> SSH -->enable (allows ssh connection from MacBook); then navigate to VNC --> enable (allows GUI access)
  7. sudo apt-get update && sudo apt-get upgrade
  8. mkdir Projects
  9. pip install virtualenv
  10. pip3 install virtualenv
  11. sudo apt-get install python-virtualenv
  12. which python3 -> show's you the directory where to find python3. For Raspberry it should be '/usr/bin/python3'
  13. virtualenv venv36 -p /usr/bin/python3
  14. source venv36/bin/activate
  15. python -V -> if you did everything right you should get something with 'Python 3.x.x'
  16. cd Projects
  17. git clone https://github.com/timgrossmann/InstaPy.git
  18. cd InstaPy
  19. sudo pip3 install .
  20. pip3 install requests selenium pyvirtualdisplay clarifai emoji regex plyer meaningcloud-python schedule
  21. sudo apt-get install tightvncserver (to view GUI from MacBook)

For Chrome

This assumes you're using the latest version of raspbian (stretch). Note that this works best running headless.

  1. Switch to the root user sudo su
  2. Update apt source lists echo "deb http://security.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list
  3. Update apt-get update
  4. Install the browser apt-get install chromium-browser
  5. Install the driver apt-get install chromedriver
  6. Move the driver into the InstaPy/assets directory mv /usr/bin/chromedriver /path/to/InstaPy/assets/chromedriver
  7. nano instapy/settings.py
  8. change "chromedriver_min_version = 2.36" to "chromedriver_min_version = 2.33" & save file

The combination of the versions of chromium-browser and chromdriver is important. This combination is currently working

  • Chromium 65.0.3325.181 Built on Raspbian , running on Raspbian 9.4
  • ChromeDriver 2.36 (a81166ad79e68fbfe7cf5ba243192d6412e26b37)

For Firefox

Remove any versions of Firefox as it will conflict with the correct one installed below:

  1. sudo apt-get remove firefox-esr
  2. sudo apt-get remove iceweasel
  3. sudo apt-get remove firefox

found the following commands to install Firefox here; https://www.q4os.org/forum/viewtopic.php?id=912

  1. echo 'deb http://q4os.org/qextrepo q4os-rpi-firefox-cn main' | sudo tee /etc/apt/sources.list.d/qextrepo.list
  2. wget -nv -O- http://q4os.org/qextrepo/q4a-q4os.gpg.pub | sudo apt-key add -
  3. sudo apt-get update
  4. sudo apt-get install firefox

Update GeckoDriver if needed. Instructions at the end of this document.

Firefox is not currently working correctly on Pi 2, to install a working version the following commands should be used:

Pi2.1. wget https://launchpad.net/~ubuntu-mozilla-security/+archive/ubuntu/ppa/+build/10930950/+files/firefox_49.0+build4-0ubuntu0.14.04.1_armhf.deb

Pi2.2 sudo dpkg -i firefox_49.0+build4-0ubuntu0.14.04.1_armhf.deb

Finishing Up

Encountered some errors when trying to run the quickstart.py and ran the next 3 commands (all may not be necessary)

  1. sudo pip install future
  2. sudo apt-get install xvfb
  3. sudo pip install pyvirtualdisplay
  4. sudo reboot (may not be required, but no harm)

Assuming you've modified quickstart.py to your liking and added your Instagram login to instapy.py

  1. sudo xvfb-run python quickstart.py

I installed TMUX to help run this headless, so that I can disconnect from the session and have the program continue to run on the rpi3

  1. sudo apt-get install tmux (more info found here: https://github.com/tmux/tmux)

  2. If using firefox, follow the example seen in examples\firefoxExample.py to set the default browser as Firefox

How to update GeckoDriver on Raspbian

New releases can be found in https://github.com/mozilla/geckodriver/releases

  1. wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-arm7hf.tar.gz
  2. tar -xvzf geckodriver-v*
  3. chmod +x geckodriver
  4. sudo cp geckodriver /usr/local/bin/

Installation with raspbian stretch lite (v4.14)

  1. sudo apt-get update && sudo apt-get upgrade
  2. sudo apt-get install chromium-browser python-pip git
  3. git clone https://github.com/timgrossmann/InstaPy.git instapy
  4. in the instapy folder: pip install .
  5. in the assets folder: wget https://github.com/electron/electron/releases/download/v3.0.0-beta.5/chromedriver-v3.0.0-beta.5-linux-armv7l.zip
  6. also in the assets folder: unzip chromedriver-v3.0.0-beta.5-linux-armv7l.zip
  7. 🎉

Solve Ensure chromedriver is installed at .. (Tested on Raspberry Pi 3 B+)

  1. Follow the complete installation above.
  2. Remove the chromedriver currently in the assets folder: 'rm chromedriver'
  3. Inside the assets folder: 'wget https://github.com/electron/electron/releases/download/v3.0.0-beta.5/chromedriver-v3.0.0-beta.5-linux-armv7l.zip'
  4. Inside the assets folder: 'unzip chromedriver-v3.0.0-beta.5-linux-armv7l.zip'
  5. 'sudo apt-get remove chromium'