marcosschroh / pyinstamation

Easy to use, config oriented, instagram bot, written in python 3
GNU General Public License v3.0
11 stars 2 forks source link

error after install #17

Closed 5p4ce closed 6 years ago

5p4ce commented 6 years ago

I ran the bot_like_and_comment got this log:

'Traceback (most recent call last):
  File "/home/pi/Projects/pyinstamation-master/bot_like_and_comment.py", line 2, in <module>
    from pyinstamation.bot import InstaBot
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/__init__.py", line 1, in <module>
    from pyinstamation.config import CONFIG
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/config.py", line 58, in <module>
    load_config()
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/config.py", line 51, in load_config
    with open(filepath, 'r') as stream:
FileNotFoundError: [Errno 2] No such file or directory: './config.yaml'
woile commented 6 years ago

You have to run make init to generate a base config, or create it yourself, you need a file config.yaml, you can check deafult.yaml

woile commented 6 years ago

Remember that you need selenium's webdriver as well, if you run make init it will be downloaded automatically, else you can run make webdriver.

5p4ce commented 6 years ago

okay, ran the make init and make webdrivier and edited the config.yaml but how do I start it? Sorry I'm new to python :)

woile commented 6 years ago

No problem at all. Always read the README of a project. To run the bot you have to run make run-bot

woile commented 6 years ago

And remember to set a proper username and password in the config.yaml

5p4ce commented 6 years ago

got that trying to run make run-bot:

python -m pyinstamation
/usr/bin/python: No module named parse; 'pyinstamation' is a package and cannot be directly executed
Makefile:8: recipe for target 'run-bot' failed
make: *** [run-bot] Error 1
woile commented 6 years ago

You have to install the dependencies pip install -r requirements.txt

5p4ce commented 6 years ago

installed it before :/

woile commented 6 years ago

Are you using python 2.7?

5p4ce commented 6 years ago

3.4.2 Bot_like_and_comment.py gave me this:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/easyprocess/__init__.py", line 225, in start
    env=self.env,
  File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'Xephyr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/easyprocess/__init__.py", line 178, in check_installed
    self.call()
  File "/usr/local/lib/python3.4/dist-packages/easyprocess/__init__.py", line 194, in call
    self.start().wait(timeout=timeout)
  File "/usr/local/lib/python3.4/dist-packages/easyprocess/__init__.py", line 230, in start
    raise EasyProcessError(self, 'start error')
easyprocess.EasyProcessError: start error <EasyProcess cmd_param=['Xephyr', '-help'] cmd=['Xephyr', '-help'] oserror=[Errno 2] No such file or directory: 'Xephyr' return_code=None stdout="None" stderr="None" timeout_happened=False>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Projects/pyinstamation-master/bot_like_and_comment.py", line 13, in <module>
    bot.start_browser()
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/bot.py", line 104, in start_browser
    self.scrapper.open_browser()
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/scrapper/base.py", line 36, in open_browser
    self.display = Display(visible=int(not self.hide_browser), size=size)
  File "/usr/local/lib/python3.4/dist-packages/pyvirtualdisplay/display.py", line 34, in __init__
    self._obj = self.display_class(
  File "/usr/local/lib/python3.4/dist-packages/pyvirtualdisplay/display.py", line 52, in display_class
    cls.check_installed()
  File "/usr/local/lib/python3.4/dist-packages/pyvirtualdisplay/xephyr.py", line 30, in check_installed
    ubuntu_package=PACKAGE).check_installed()
  File "/usr/local/lib/python3.4/dist-packages/easyprocess/__init__.py", line 180, in check_installed
    raise EasyProcessCheckInstalledError(self)
easyprocess.EasyProcessCheckInstalledError: cmd=['Xephyr', '-help']
OSError=[Errno 2] No such file or directory: 'Xephyr'
Program install error! 
woile commented 6 years ago

Try installing this dep sudo apt-get install xvfb

5p4ce commented 6 years ago

installed it, same issue.

woile commented 6 years ago

This one sudo apt-get install xserver-xephyr ?

You are missing the dependency that creates a "virtual window"

5p4ce commented 6 years ago

sorry for all the hassle, it worked, it opens a black window, but now i get:

Traceback (most recent call last):
  File "/home/pi/Projects/pyinstamation-master/bot_like_and_comment.py", line 13, in <module>
    bot.start_browser()
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/bot.py", line 104, in start_browser
    self.scrapper.open_browser()
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/scrapper/base.py", line 38, in open_browser
    self.browser = self._open_mobile_browser()
  File "/home/pi/Projects/pyinstamation-master/pyinstamation/scrapper/base.py", line 53, in _open_mobile_browser
    desired_capabilities=chrome_options.to_capabilities())
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/common/service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
woile commented 6 years ago

Don't worry, you are the first giving us some real feedback, this is helping us. Let me see. Just in case check that you've followed the instructions to install pyvirtualenv http://pyvirtualdisplay.readthedocs.io/en/latest/#ubuntu-14-04

woile commented 6 years ago

There is an error with the downloaded chromedriver. Try downloading manually, select the proper item from this list, unzip it and place it inside the folder assets.

woile commented 6 years ago

And remember to set the name of the driver to chromedriver. Though I think it's already called like that

5p4ce commented 6 years ago

fetched the new driver, copied it with the same name, still the same issue :/

woile commented 6 years ago

mmmm that's strange, looks like you have the wrong binary for your system, run in your terminal getconf LONG_BIT and check if you downloaded the correct version for that architecture.

5p4ce commented 6 years ago

On Raspberry as well on Ost still the same issue:

python -m pyinstamation
/usr/bin/python: No module named parse; 'pyinstamation' is a package and cannot be directly executed
make: *** [run-bot] Error 1

done everything exactly like in the readme.

woile commented 6 years ago

@eigentlichich I'll submit a potential fix to that issue. Give me a moment

If you are going to use raspberry remember to use a chromedriver for ARM architecture, you can get them from here

woile commented 6 years ago

You can read more on selenium's chromedriver for raspberry here https://stackoverflow.com/questions/31190164/using-selenium-on-raspberry-pi-with-chromium

woile commented 6 years ago

@eigentlichich try now, in theory you should not have that error anymore.

5p4ce commented 6 years ago

Back again :) so after a while i tried a lot an now it seems that the driver is the last part which makes some problems :)

pi@raspberrypi:~/Projects/pyinstamation-master $ make run-bot
python -m pyinstamation
2017-10-16 07:58:37,555 [ERROR] Something happened. Tracking to fix
Traceback (most recent call last):
  File "pyinstamation/bot.py", line 490, in run
    self.start_browser()
  File "pyinstamation/bot.py", line 106, in start_browser
    self.scrapper.open_browser()
  File "pyinstamation/scrapper/base.py", line 39, in open_browser
    self.browser = self._open_mobile_browser()
  File "pyinstamation/scrapper/base.py", line 54, in _open_mobile_browser
    desired_capabilities=chrome_options.to_capabilities())
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 96, in start
    self.assert_process_still_running()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
WebDriverException: Message: Service ./assets/chromedriver unexpectedly exited. Status code was: 127

2017-10-16 07:58:37,585 [DEBUG] Not logged in
2017-10-16 07:58:37,585 [DEBUG] Closing browser...
2017-10-16 07:58:38,214 [INFO] FINAL STATS
2017-10-16 07:58:38,215 [INFO] Posts explored: 0
2017-10-16 07:58:38,216 [INFO] Likes: 0
2017-10-16 07:58:38,217 [INFO] Comments: 0
2017-10-16 07:58:38,217 [INFO] Followed: 0
2017-10-16 07:58:38,218 [INFO] Unfollowed: 0

whats the correct chromium driver for the raspberry pi 3 - sorry if its actually easy :)

woile commented 6 years ago

Please check the readme in troubleshooting for chrome driver for raspberry. That's all I know. Remember that the bot was written in python 3, so to avoid more conflicts you should not use python 2.7.

5p4ce commented 6 years ago

tried every driver from the troubleshooting Link and checkt every StackOverflow. seems that chromium won't work for raspberry, saw some who used selenium and firefox to run the automation.

marcosschroh commented 6 years ago

Hi @eigentlichich,

The project only works with Chrome WebDriver but you can change it to Firefox if you want.

You have to install the Firebox WebDriver and change the code in https://github.com/discov-r/pyinstamation/blob/master/pyinstamation/scrapper/base.py#L52

I will try to use the FIrebox WebDriver as well.

Best regards.

5p4ce commented 6 years ago

Hi @marcosschroh, I have still no clue how to change to firefox :/ any news?

marcosschroh commented 6 years ago

Hi @eigentlichich

We have a new branch: https://github.com/dscovr/pyinstamation/tree/firefox-support

Try to use this new branch and:

  1. run the command make webdriver to fetch the drivers again
  2. set browser_type: firefox in the config.yaml file.
  3. execute make run-bot
5p4ce commented 6 years ago

Works like a charm! Thanks @marcosschroh

marcosschroh commented 6 years ago

You're welcome. Thanks for the feedback @eigentlichich