After pulling the newest InstaPy I get the following error โ most likely caused by this #3318 PR.
pip install .
has been run successfullypython 2.7
โ python qs-likes.py
Traceback (most recent call last):
File "qs-likes.py", line 17, in <module>
disable_image_load=True)
File "/Users/oskarkrawczyk/Sites/InstaPy/instapy/instapy.py", line 250, in __init__
self.set_selenium_local_session()
File "/Users/oskarkrawczyk/Sites/InstaPy/instapy/instapy.py", line 391, in set_selenium_local_session
highlight_print(self.username, message, "initialization", "info", self.logger)
File "/Users/oskarkrawczyk/Sites/InstaPy/instapy/util.py", line 929, in highlight_print
print("\n{}".format(upper_char * ceil(output_len/len(upper_char))))
TypeError: can't multiply sequence by non-int of type 'float'
This is the quickstart file:
import random
from instapy import InstaPy
from instapy.util import smart_run
# login credentials
insta_username = '...'
insta_password = '...'
# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=True,
disable_image_load=True)
with smart_run(session):
""" Activity flow """
like_tag_list = [
'taintedmag',
'thinkverylittle',
'verybusymag',
'dreamermagazine',
'lightzine',
'indiependentmag',
'collecmag',
'noicemag',
'everybodyfilm',
'believeinfilm',
'theanalogclub',
'specialfilm',
'kodaklosers'
]
session.set_simulation(enabled=False)
session.set_skip_users(
skip_private=True,
private_percentage=100
)
session.set_quota_supervisor(
enabled=True,
sleep_after=["likes", "comments_d", "follows", "unfollows", "server_calls_h"],
sleepyhead=True,
stochastic_flow=True,
notify_me=False,
peak_likes=(107, 585),
peak_comments=(31, 182),
peak_follows=(48, None),
peak_unfollows=(35, 402),
peak_server_calls=(None, 4700)
)
session.set_relationship_bounds(
enabled=True,
# potency_ratio=1,
delimit_by_numbers=True,
max_followers=4590,
min_followers=45,
min_following=77
)
# users with high amount of likes usually don't interact with other people
session.set_delimit_liking(enabled=True, max=600, min=5)
session.set_user_interact(amount=random.randint(2, 5), randomize=True, percentage=90)
session.set_do_like(enabled=True, percentage=90)
# session.like_by_tags(like_tag_list, amount=random.randint(200, 1000), interact=True)
session.set_smart_hashtags(like_tag_list, limit=3, sort='top', log_tags=True)
session.like_by_tags(amount=random.randint(200, 1000), interact=True, use_smart_hashtags=True)
@uluQulu
I get strange errors too.
I mostly receive NameError: name 'session' is not defined
I strongly suppose is not Python 2.7 compliant
@redsector72 correct!
Installed Python 3, reinstalled the whole app (pip3 install .
) and that did the trick.
Getting the same error, as well as numerous ones before it. Updated chromedriver, updated repo, ran pip install .
and getting can't multiply sequence by non-int of type 'float'
Full error with some local info redacted is:
Traceback (most recent call last):
File "hashtag-XXXxxxXXX.py", line 15, in <module>
headless_browser=True)
File "/home/XXXxxxXXX/InstaPy-XXXxxxXXX/instapy/instapy.py", line 250, in __init__
self.set_selenium_local_session()
File "/home/XXXxxxXXX/InstaPy-XXXxxxXXX/instapy/instapy.py", line 391, in set_selenium_local_session
highlight_print(self.username, message, "initialization", "info", self.logger)
File "/home/XXXxxxXXX/InstaPy-XXXxxxXXX/instapy/util.py", line 929, in highlight_print
print("\n{}".format(upper_char * ceil(output_len/len(upper_char))))
TypeError: can't multiply sequence by non-int of type 'float'
Running Python 2.7.13 on a Chromebook. Hoping the only solution isn't to upgrade to Python 3.
Thanks for all the amazing work put in by contributors and developers ๐ฏ
Apparently I haven't had enough coffee and have Python 3.5.3 already installed.
When I run the same InstaPy file using `$ python3 hashtag-XXXxxxXXX.py I get the following:
File "hashtag-XXXxxxXXX.py", line 2, in <module>
from instapy import InstaPy
File "/home/XXXxxxXXX/InstaPy-XXXxxxXXX/instapy/__init__.py", line 3, in <module>
from .instapy import InstaPy
File "/home/XXXxxxXXX/InstaPy-XXXxxxXXX/instapy/instapy.py", line 12, in <module>
import requests
ImportError: No module named 'requests'
Thanks for all the amazing work put in by contributors and developers ๐ฏ
@axlright You have to install requirements using pip3
, the old ones won't work
@oskarkrawczyk I was thinking that is the issue. I need to figure out how to do that now : )
By the way, I really dig your quickstart file. Is there a good place to chat outside of this thread about your strategy with that quickstart file?
@axlright DM on Twitter or IG
@oskarkrawczyk thanks for the help. Can confirm that after installing python3, pip3 and running $ pip3 install .
and then running the InstaPy file via python3 hashtag-XXXxxxXXX.py
everything is now working smoothly.
Guess it was time for an upgrade anyways...
@oskarkrawczyk I'll hit you up in a DM on Twitter. Thanks!
My mistake ๐
@timgrossmann @axlright @oskarkrawczyk
In python 3, ceil(float)
returns integer
[as expected] but I just found out that, it returns float
in python 2.
from math import ceil
zx = 9.02
result = ceil(zx)
| python _version_ | result | result's type |
| ----------- | --------- | ----- |
| 2 | 10
| integer |
| 3 | 10.0
| float |
So, as we need integer,
replacing,
print("\n{}".format(upper_char * ceil(output_len/len(upper_char))))
with,
print("\n{}".format(upper_char * int(ceil(output_len/len(upper_char)))))
will solve the issue (_it's just int(ceil(float))
now, rather than ceil(float)
_).
That line to be changed is at util.py file, highlight_print
definition.
@axlright
Hoping the only solution isn't to upgrade to Python 3.
No you don't need to.
Same problem with #3469 from meinert/patch-2
$ git show-branch
[master] Merge pull request #3469 from meinert/patch-2
Using:
$ python -V
Python 2.7.15+
$ python quickstart.py
Traceback (most recent call last):
File "quickstart.py", line 16, in <module>
headless_browser=True)
File "/home/elulcao/Projects/InstaPy/instapy/instapy.py", line 252, in __init__
self.set_selenium_local_session()
File "/home/elulcao/Projects/InstaPy/instapy/instapy.py", line 393, in set_selenium_local_session
highlight_print(self.username, message, "initialization", "info", self.logger)
File "/home/elulcao/Projects/InstaPy/instapy/util.py", line 931, in highlight_print
print("\n{}".format(upper_char * ceil(output_len/len(upper_char))))
TypeError: can't multiply sequence by non-int of type 'float'
The only WA I found is running with python3:
$ python3 quickstart.py
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
INFO [2018-12-01 20:48:11] [elulcao] Session started!
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Hey Gonzales!
You can apply the 1 line of change to solve it by reading my previous comment.
It's also included in my live PR ๐
Most helpful comment
My mistake ๐
@timgrossmann @axlright @oskarkrawczyk
In python 3,
ceil(float)
returnsinteger
[as expected] but I just found out that, it returnsfloat
in python 2.| python _version_ | result | result's type |
| ----------- | --------- | ----- |
| 2 |
10
| integer || 3 |
10.0
| float |So, as we need integer,
replacing,
with,
will solve the issue (_it's just
int(ceil(float))
now, rather thanceil(float)
_).That line to be changed is at util.py file,
highlight_print
definition.@axlright
No you don't need to.
Cheers ๐