InstaPy icon indicating copy to clipboard operation
InstaPy copied to clipboard

ValueError: Sample larger than population or is negative

Open TheNighthawk99 opened this issue 4 years ago • 6 comments

Hello, last night it was working well, since today noon I get this error.

Running in headless_browser=True if needed.

__________________________________________________________________________________________
INFO [2022-02-11 21:35:40] [usr]  Starting to follow user `Followers`..
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
INFO [2022-02-11 21:35:40] [usr]  User 'melissariso' [1/2]
INFO [2022-02-11 21:35:50] [usr]  GraphQL query hash: [c76146de99bb02f6415203be841dd25a]

INFO [2022-02-11 21:35:53] [usr]  Sessional Live Report:
        |> No any statistics to show

On session start was FOLLOWING 2067 users & had 55900 FOLLOWERS
[Session lasted 1.61 minutes]
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2022-02-11 21:35:53] [usr]  Session ended!
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo



Traceback (most recent call last):
  File "quickstart.py", line 25, in <module>
    session.follow_user_followers(['melissariso'], amount=25, randomize=True, interact=True)
  File "/home/usr/git/InstaPy/instapy/instapy.py", line 3678, in follow_user_followers
    person_list, simulated_list = get_given_user_followers(
  File "/home/usr/git/InstaPy/instapy/unfollow_util.py", line 1007, in get_given_user_followers
    person_list, simulated_list = get_users_through_dialog_with_graphql(
  File "/home/usr/git/InstaPy/instapy/unfollow_util.py", line 825, in get_users_through_dialog_with_graphql
    followers_list = random.sample(followers_list, real_amount)
  File "/usr/lib/python3.8/random.py", line 363, in sample
    raise ValueError("Sample larger than population or is negative")
ValueError: Sample larger than population or is negative

TheNighthawk99 avatar Feb 11 '22 20:02 TheNighthawk99

No one is getting this error?

TheNighthawk99 avatar Feb 14 '22 07:02 TheNighthawk99

@TheNighthawk99 I just had this error too. Pretty random as I've been running without errors for a few days.

mr-ravicii avatar Feb 15 '22 07:02 mr-ravicii

@TheNighthawk99 I just had this error too. Pretty random as I've been running without errors for a few days.

I am running InstaPy on two VMs, both with headless_browser=True. In the first one I have been running in the last weeks, then suddenly got this error. In the second one, it is running regularly, hope it keeps. I cannot understand why.

TheNighthawk99 avatar Feb 15 '22 08:02 TheNighthawk99

Yeah, also not sure what is happening. I've been running for several hours today and have not seen the error message again.

mr-ravicii avatar Feb 16 '22 12:02 mr-ravicii

is this issue fixed in any way?

TheNighthawk99 avatar Feb 27 '22 16:02 TheNighthawk99

try changing

File "/home/usr/git/InstaPy/instapy/unfollow_util.py", line 825, in get_users_through_dialog_with_graphql followers_list = random.sample(followers_list, real_amount)

with followers_list = random.sample(followers_list, min(followers_list, real_amount))

dimitri-ognibene avatar Mar 11 '22 21:03 dimitri-ognibene