Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named pyvirtualdisplay to run InstaPy-Light #2

Open
june2kicks opened this issue Sep 14, 2018 · 8 comments
Open

Comments

@june2kicks
Copy link

  • Geckodriver version 0.21
  • Firefox: 62.0
  • Python: 3.7
  • Selenium: 3.14.0
  • Pyvirtualdisplay: 0.2.1

Hi,

I tried to run InstaPy-Light. I made everything like in the tutorial video: https://www.youtube.com/watch?v=h9svDhveps8 but I have got an issue when I try to run it.

I put my info on the config.py and lunch python config.py but nothing happened.

My code:

Last login: Fri Sep 14 16:47:20 on ttys000

MacBook-Pro-de-June2kicks:~ june2kicks$ cd documents
MacBook-Pro-de-June2kicks:documents june2kicks$ cd webdriver
MacBook-Pro-de-June2kicks:webdriver june2kicks$ curl -LO https://github.com/converge/InstaPy-Light/archive/master.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   127    0   127    0     0    285      0 --:--:-- --:--:-- --:--:--   285
100 5494k    0 5494k    0     0  2369k      0 --:--:--  0:00:02 --:--:-- 4921k
MacBook-Pro-de-June2kicks:webdriver june2kicks$ unzip master.zip
Archive:  master.zip
6c497c8fd606f08ab20dec870b4c9d7fb508e337
   creating: InstaPy-Light-master/
  inflating: InstaPy-Light-master/LICENSE  
  inflating: InstaPy-Light-master/README.md  
   creating: InstaPy-Light-master/app/
  inflating: InstaPy-Light-master/app/__init__.py  
  inflating: InstaPy-Light-master/app/blacklist.py  
  inflating: InstaPy-Light-master/app/instapy.py  
  inflating: InstaPy-Light-master/app/like.py  
  inflating: InstaPy-Light-master/app/login.py  
  inflating: InstaPy-Light-master/app/print_log_writer.py  
  inflating: InstaPy-Light-master/app/profile.py  
  inflating: InstaPy-Light-master/app/time_util.py  
  inflating: InstaPy-Light-master/app/unfollow.py  
  inflating: InstaPy-Light-master/app/util.py  
  inflating: InstaPy-Light-master/config.py  
   creating: InstaPy-Light-master/db/
  inflating: InstaPy-Light-master/db/instapy-light.db  
   creating: InstaPy-Light-master/docs/
 extracting: InstaPy-Light-master/docs/.nojekyll  
  inflating: InstaPy-Light-master/docs/How_To_DO_Ubuntu_on_Digital_Ocean.md  
  inflating: InstaPy-Light-master/docs/Makefile  
  inflating: InstaPy-Light-master/docs/erm.mwb  
   creating: InstaPy-Light-master/docs/html/
  inflating: InstaPy-Light-master/docs/html/.buildinfo  
   creating: InstaPy-Light-master/docs/html/_sources/
  inflating: InstaPy-Light-master/docs/html/_sources/blacklist.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/index.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/instapy.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/like.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/login.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/profile.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/time_util.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/unfollow.rst.txt  
  inflating: InstaPy-Light-master/docs/html/_sources/util.rst.txt  
   creating: InstaPy-Light-master/docs/html/_static/
  inflating: InstaPy-Light-master/docs/html/_static/ajax-loader.gif  
  inflating: InstaPy-Light-master/docs/html/_static/basic.css  
 extracting: InstaPy-Light-master/docs/html/_static/comment-bright.png  
 extracting: InstaPy-Light-master/docs/html/_static/comment-close.png  
 extracting: InstaPy-Light-master/docs/html/_static/comment.png  
   creating: InstaPy-Light-master/docs/html/_static/css/
  inflating: InstaPy-Light-master/docs/html/_static/css/badge_only.css  
  inflating: InstaPy-Light-master/docs/html/_static/css/theme.css  
  inflating: InstaPy-Light-master/docs/html/_static/doctools.js  
  inflating: InstaPy-Light-master/docs/html/_static/documentation_options.js  
 extracting: InstaPy-Light-master/docs/html/_static/down-pressed.png  
 extracting: InstaPy-Light-master/docs/html/_static/down.png  
 extracting: InstaPy-Light-master/docs/html/_static/file.png  
   creating: InstaPy-Light-master/docs/html/_static/fonts/
   creating: InstaPy-Light-master/docs/html/_static/fonts/Lato/
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bold.eot  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bold.ttf  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bold.woff  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bold.woff2  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bolditalic.eot  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bolditalic.ttf  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bolditalic.woff  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-bolditalic.woff2  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-italic.eot  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-italic.ttf  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-italic.woff  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-italic.woff2  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-regular.eot  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-regular.ttf  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-regular.woff  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/Lato/lato-regular.woff2  
   creating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/fontawesome-webfont.eot  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/fontawesome-webfont.svg  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/fontawesome-webfont.ttf  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/fontawesome-webfont.woff  
  inflating: InstaPy-Light-master/docs/html/_static/fonts/fontawesome-webfont.woff2  
  inflating: InstaPy-Light-master/docs/html/_static/jquery-3.2.1.js  
  inflating: InstaPy-Light-master/docs/html/_static/jquery.js  
   creating: InstaPy-Light-master/docs/html/_static/js/
  inflating: InstaPy-Light-master/docs/html/_static/js/modernizr.min.js  
  inflating: InstaPy-Light-master/docs/html/_static/js/theme.js  
  inflating: InstaPy-Light-master/docs/html/_static/minus.png  
  inflating: InstaPy-Light-master/docs/html/_static/plus.png  
  inflating: InstaPy-Light-master/docs/html/_static/pygments.css  
  inflating: InstaPy-Light-master/docs/html/_static/searchtools.js  
  inflating: InstaPy-Light-master/docs/html/_static/underscore-1.3.1.js  
  inflating: InstaPy-Light-master/docs/html/_static/underscore.js  
 extracting: InstaPy-Light-master/docs/html/_static/up-pressed.png  
 extracting: InstaPy-Light-master/docs/html/_static/up.png  
  inflating: InstaPy-Light-master/docs/html/_static/websupport.js  
  inflating: InstaPy-Light-master/docs/html/blacklist.html  
  inflating: InstaPy-Light-master/docs/html/genindex.html  
  inflating: InstaPy-Light-master/docs/html/index.html  
  inflating: InstaPy-Light-master/docs/html/instapy.html  
  inflating: InstaPy-Light-master/docs/html/like.html  
  inflating: InstaPy-Light-master/docs/html/login.html  
 extracting: InstaPy-Light-master/docs/html/objects.inv  
  inflating: InstaPy-Light-master/docs/html/profile.html  
  inflating: InstaPy-Light-master/docs/html/py-modindex.html  
  inflating: InstaPy-Light-master/docs/html/search.html  
  inflating: InstaPy-Light-master/docs/html/searchindex.js  
  inflating: InstaPy-Light-master/docs/html/time_util.html  
  inflating: InstaPy-Light-master/docs/html/unfollow.html  
  inflating: InstaPy-Light-master/docs/html/util.html  
  inflating: InstaPy-Light-master/docs/index.html  
   creating: InstaPy-Light-master/docs/source/
  inflating: InstaPy-Light-master/docs/source/.DS_Store  
  inflating: InstaPy-Light-master/docs/source/blacklist.rst  
  inflating: InstaPy-Light-master/docs/source/conf.py  
  inflating: InstaPy-Light-master/docs/source/index.rst  
  inflating: InstaPy-Light-master/docs/source/instapy.rst  
  inflating: InstaPy-Light-master/docs/source/like.rst  
  inflating: InstaPy-Light-master/docs/source/login.rst  
  inflating: InstaPy-Light-master/docs/source/profile.rst  
  inflating: InstaPy-Light-master/docs/source/time_util.rst  
  inflating: InstaPy-Light-master/docs/source/unfollow.rst  
  inflating: InstaPy-Light-master/docs/source/util.rst  
   creating: InstaPy-Light-master/logs/
  inflating: InstaPy-Light-master/logs/.gitignore  

MacBook-Pro-de-June2kicks:webdriver june2kicks$ cd instapy-light-master
MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ pip3 install requests selenium pyvirtualdisplay
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.19.1)
Requirement already satisfied: selenium in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (3.14.0)
Requirement already satisfied: pyvirtualdisplay in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.2.1)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (2018.8.24)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna<2.8,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (2.7)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (1.23)
Requirement already satisfied: EasyProcess in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pyvirtualdisplay) (0.2.3)
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.


MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ python --version
Python 2.7.10
MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ pyhton3 --version
-bash: pyhton3: command not found
MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ python3 --version
Python 3.7.0


MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ python config.py
Traceback (most recent call last):
  File "config.py", line 5, in <module>
    from app import InstaPyLight
  File "/Users/june2kicks/Documents/WebDriver/InstaPy-Light-master/app/__init__.py", line 1, in <module>
    from .instapy import InstaPyLight
  File "/Users/june2kicks/Documents/WebDriver/InstaPy-Light-master/app/instapy.py", line 9, in <module>
    from pyvirtualdisplay import Display
ImportError: No module named pyvirtualdisplay
MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$

Did I miss something?

Cheers

@converge
Copy link
Owner

there is a little detail:

python3 config.py not python config.py

:D

@june2kicks
Copy link
Author

How I feel so stupid :(

Now I have got an other issue.

Everything run correctly but when I want to connect to instagram is ok for 2s and after everything disappear and I have the following message on terminal.
I receive an email from instagram too that tell that there is a suspicious activity on my account.

Last login: Fri Sep 14 19:14:08 on ttys000
MacBook-Pro-de-June2kicks:~ june2kicks$ cd documents
MacBook-Pro-de-June2kicks:documents june2kicks$ cd webdriver
MacBook-Pro-de-June2kicks:webdriver june2kicks$ cd instapy-light-master
MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ python3 config.py
18-09-14 19:29:28 INFO - Session started
Cookie file not found, creating cookie...
18-09-14 19:30:00 INFO - Session ended - 2018-09-14 19:30:00
18-09-14 19:30:00 INFO - --------------------


Traceback (most recent call last):
  File "config.py", line 33, in <module>
    session.login()
  File "/Users/june2kicks/Documents/WebDriver/InstaPy-Light-master/app/instapy.py", line 207, in login
    self.bypass_suspicious_attempt):
  File "/Users/june2kicks/Documents/WebDriver/InstaPy-Light-master/app/login.py", line 135, in login_user
    "//article/div/div/p/a[text()='Log in']")
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 393, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 966, in find_element
    'value': value})['value']
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //article/div/div/p/a[text()='Log in']

MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ 

I am really sorry I never code before.

Any ideas?

Cheers

@converge
Copy link
Owner

converge commented Sep 14, 2018

don't worry, fail is part of success! you can add this option to bypass suspicious login attempt:

bypass_suspicious_attempt

example:

session = InstaPyLight(username='',
                       password='',
                       bypass_suspicious_attempt=True,
                       headless=False)

after first successful login, you can delete the bypass_suspicious_attempt line

@june2kicks
Copy link
Author

june2kicks commented Sep 14, 2018

thanks a lot you are really helpfull.

So I did what you said but now I have got this message.

Last login: Fri Sep 14 19:28:31 on ttys000
MacBook-Pro-de-June2kicks:~ june2kicks$ cd documents
MacBook-Pro-de-June2kicks:documents june2kicks$ cd webdriver
MacBook-Pro-de-June2kicks:webdriver june2kicks$ cd instapy-light-master
MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ python3 config.py
18-09-14 19:53:57 INFO - Session started
Cookie file not found, creating cookie...
18-09-14 19:54:27 INFO - Session ended - 2018-09-14 19:54:27
18-09-14 19:54:27 INFO - --------------------


Traceback (most recent call last):
  File "config.py", line 34, in <module>
    session.login()
  File "/Users/june2kicks/Documents/WebDriver/InstaPy-Light-master/app/instapy.py", line 207, in login
    self.bypass_suspicious_attempt):
  File "/Users/june2kicks/Documents/WebDriver/InstaPy-Light-master/app/login.py", line 135, in login_user
    "//article/div/div/p/a[text()='Log in']")
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 393, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 966, in find_element
    'value': value})['value']
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //article/div/div/p/a[text()='Log in']

MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ 

I think there is an issue with the creating cookie part.

Cheers

@converge
Copy link
Owner

the cookie behavior is ok, when there is no cookie yet (first time you run the script), it will show that message.

I tried the bypass suspicious feature, and it´s working fine. What last_screen.png shows you ?

@june2kicks
Copy link
Author

Sorry, I didn't receive any notification for your answer.

So now I can connect but it disconnect right away after connexion (see below).

Last login: Sun Sep 16 14:52:51 on ttys000
MacBook-Pro-de-June2kicks:~ june2kicks$ cd documents
MacBook-Pro-de-June2kicks:documents june2kicks$ cd webdriver
MacBook-Pro-de-June2kicks:webdriver june2kicks$ cd instapy-light-master
MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ python3 config.py
18-09-16 14:56:35 INFO - Session started
18-09-16 14:56:38 INFO - Logged in successfully!
18-09-16 14:56:39 INFO - Session ended - 2018-09-16 14:56:39
18-09-16 14:56:39 INFO - --------------------


MacBook-Pro-de-June2kicks:instapy-light-master june2kicks$ 

Here the last_screen.png I have got:

last_screen

Cheers

@converge
Copy link
Owner

everything is good, it connects and login successfully, now you need to add the features you want to use in the config.py file

@june2kicks
Copy link
Author

yes, I figured out just after I put my message, I am gonna follow all your tutorial now to customize my own bot.

Thanks a lot.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants