Instapy: Unfollow loop error: unsupported operand type(s) for *: 'NoneType' and 'float'

Created on 13 Sep 2018  路  4Comments  路  Source: timgrossmann/InstaPy

Expected Behavior

Unfollow the requested amount

Current Behavior

After 9-12 unfollows, i get the error below:
ERROR [2018-09-13 00:59:59] [user] Unfollow loop error: unsupported operand type(s) for *: 'NoneType' and 'float'.
This error occured on the Unfollow methods below:
customList
InstapyFollowed

Possible Solution (optional)

InstaPy configuration

import os
import time
from tempfile import gettempdir

from selenium.common.exceptions import NoSuchElementException

from instapy import InstaPy

session = InstaPy(headless_browser=True,
multi_logs=True,
bypass_suspicious_attempt=False)

try:
session.login()
session.set_dont_include(['user'])
session.unfollow_users(amount=50, InstapyFollowed=(True, "all"), style="FIFO", unfollow_after=246060, sleep_delay=None)

except Exception as exc:
# if changes to IG layout, upload the file to help us locate the change
if isinstance(exc, NoSuchElementException):
file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
with open(file_path, 'wb') as fp:
fp.write(session.browser.page_source.encode('utf8'))
print('{0}nIf raising an issue, please also upload the file located at:n{1}n{0}'.format(
'*' * 70, file_path))
# full stacktrace when raising Github issue
raise

finally:
# end the bot session
session.end()

Most helpful comment

thank you so much @uluQulu!
your solution worked perfect :)

All 4 comments

@adisch79
Make sure you are running the latest files.

If the issue persists, post the full traceback of the error from the console output.
_Details are important_.


Cheers 馃榿

@adisch79
Make sure you are running the latest files.

If the issue persists, post the full traceback of the error from the console output.
_Details are important_.

Cheers 馃榿

@uluQulu
Thank you for the response and help :)
I'm running the latest files and the issue persist - i can verify that it happens on both headless_browser modes (true and false).
Here is the full console output:

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2018-09-13 19:05:50] [username] Session started!
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

....................................................................
INFO [2018-09-13 19:06:28] [username] Logged in successfully!
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


INFO [2018-09-13 19:06:32] [username] Starting to unfollow users..
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
INFO [2018-09-13 19:06:32] [username] Unfollowing the users followed by InstaPy

INFO [2018-09-13 19:06:32] [username] Retrieving live Followers data of user at "full" range
1056/1055 [===================================+] 100% |> Elapsed: 52.73 seconds |> ETA: 0.0 seconds

INFO [2018-09-13 19:07:27] [username] Grabbed 1056 usernames from Followers in 52.73 seconds
INFO [2018-09-13 19:07:27] [username] Stored Followers data at e:InstaPylogsusername/relationship_data/username/followers/13-09-2018~full~1056.json local file

INFO [2018-09-13 19:07:27] [username] Zz :[ time to take a good nap ~sleeping 2.1 minutes
INFO [2018-09-13 19:09:15] [username] Yawn :] let's go!

INFO [2018-09-13 19:09:15] [username] Found 65 loyal followers! ~will not unfollow them
INFO [2018-09-13 19:09:15] [username] Total 46 users available to unfollow ~didn't pass unfollow_after: 0

INFO [2018-09-13 19:09:15] [username] You have requested more amount: 50 than 46 of users available to unfollow~using available amount

INFO [2018-09-13 19:09:23] [username] Ongoing Unfollow [1/46]: now unfollowing 'b'user1''...
INFO [2018-09-13 19:09:32] [username] --> Unfollowed 'user1'!
INFO [2018-09-13 19:09:32] [username] Removed '2018-09-13 08:29 ~ user1~ 000000001' from followedPool.csv file

INFO [2018-09-13 19:09:40] [username] Ongoing Unfollow [2/46]: now unfollowing 'b'user2''...
INFO [2018-09-13 19:09:50] [username] --> Unfollowed 'user2'!
INFO [2018-09-13 19:09:50] [username] Removed '2018-09-13 08:38 ~ user2 ~ 000000002' from followedPool.csv file

INFO [2018-09-13 19:09:58] [username] Ongoing Unfollow [3/46]: now unfollowing 'b'user3''...
INFO [2018-09-13 19:10:06] [username] --> Unfollowed 'user3'!
INFO [2018-09-13 19:10:07] [username] Removed '2018-09-13 08:39 ~ user3 ~ 000000003' from followedPool.csv file

INFO [2018-09-13 19:10:15] [username] Ongoing Unfollow [4/46]: now unfollowing 'b'user4''...
INFO [2018-09-13 19:10:25] [username] --> Unfollowed 'user4'!
INFO [2018-09-13 19:10:25] [username] Removed '2018-09-13 08:41 ~ user4 ~ 000000004' from followedPool.csv file

INFO [2018-09-13 19:10:36] [username] Ongoing Unfollow [5/46]: now unfollowing 'b'user5''...
INFO [2018-09-13 19:10:47] [username] --> Unfollowed 'user5'!
INFO [2018-09-13 19:10:47] [username] Removed '2018-09-13 08:43 ~ user5 ~ 000000005' from followedPool.csv file

INFO [2018-09-13 19:10:59] [username] Ongoing Unfollow [6/46]: now unfollowing 'b'user6''...
INFO [2018-09-13 19:11:06] [username] --> Unfollowed 'user6'!
INFO [2018-09-13 19:11:06] [username] Removed '2018-09-13 08:46 ~ user6 ~ 000000006' from followedPool.csv file

INFO [2018-09-13 19:11:18] [username] Ongoing Unfollow [7/46]: now unfollowing 'b'user7''...
INFO [2018-09-13 19:11:28] [username] --> Unfollowed 'user7'!
INFO [2018-09-13 19:11:29] [username] Removed '2018-09-13 08:48 ~ user7 ~ 000000007' from followedPool.csv file

INFO [2018-09-13 19:11:39] [username] Ongoing Unfollow [8/46]: now unfollowing 'b'user8''...
INFO [2018-09-13 19:11:52] [username] --> Unfollowed 'user8'!
INFO [2018-09-13 19:11:52] [username] Removed '2018-09-13 09:01 ~ user8 ~ 000000008' from followedPool.csv file

ERROR [2018-09-13 19:12:02] [username] Unfollow loop error: unsupported operand type(s) for *: 'NoneType' and 'float'

INFO [2018-09-13 19:12:02] [username] --> Total people unfollowed : 8

INFO [2018-09-13 19:12:04] [username] Sessional Live Report:
|> LIKED 0 images | ALREADY LIKED: 0
|> COMMENTED on 0 images
|> FOLLOWED 0 users | ALREADY FOLLOWED: 0
|> UNFOLLOWED 8 users
|> INAPPROPRIATE images: 0
|> NOT VALID users: 0
currently FOLLOWING 788 users & has got 1055 FOLLOWERS

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2018-09-13 19:12:04] [username] Session ended!
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

You're welcome @adisch79

Well you have put sleep_delay=None in unfollow_users() parameters which is what making the problem.
I really do not recommend using None as its value cos there really should be some sleep delay after ~10x activity.

But it is up to you and I will provide a solution for you,

To solve, open up unfollow_util.py file AND in unfollow() definition do this modification:

1-) replace

if sleep_counter >= sleep_after:

with

if sleep_counter >= sleep_after and sleep_delay not in [0, None]:

2-) replace

                if (unfollowNum != 0 and
                        hasSlept is False and
                            unfollowNum % 10 == 0):

with

                if (unfollowNum != 0 and
                        hasSlept is False and
                            unfollowNum % 10 == 0 and
                                sleep_delay not in [0, None]):

Cheers 馃榿

thank you so much @uluQulu!
your solution worked perfect :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drcyber975 picture drcyber975  路  3Comments

harrypython picture harrypython  路  3Comments

neomh picture neomh  路  3Comments

rahulkapoor90 picture rahulkapoor90  路  3Comments

Spyd3r0us picture Spyd3r0us  路  3Comments