jarrodnorwell / InstaPy2

Instagram automation tool for farming comments, follows and likes, written in Python
GNU General Public License v3.0
49 stars 9 forks source link

ImportError: attempted relative import with no known parent package #35

Closed rogersillyface closed 10 months ago

rogersillyface commented 1 year ago

Hey There,

I'm trying to use an old Instapy qucikstart file for likes and trie to combine it with the sole qiuickstart guide in the documentation.

It spits back this:

from .utilities import LoggerConstants, Utility

ImportError: attempted relative import with no known parent package

It looks like theres an issue with the first llne of the instapy file.. but I haven't touched that so no idea what the issue could be.

Quickstart (edited):

from instapy2 import InstaPy2 from instapy2.types import CommentType

create a new session

session = InstaPy2()

login to your account

session.login(username='', password='')

enables commenting

session.configuration.comments.set_enabled(enable=False)

set the list of comments to use

session.configuration.comments.set_comments(comments=[ 'wow', # this is a normal comment 'wow :thumbsup:', # this is a comment with an emoji 'wow {}', # this is a comment tagging the user ])

0-100, higher means higher change of commenting (per media)

session.configuration.comments.set_percentage(percentage=55)

this will comment on 10 media from the pk above

session.comment(amount=10, iterable=[pk], type=CommentType.Locations)

let's go! :>

with smart_run(session):

settings

session.set_user_interact(amount=3, randomize=True, percentage=100,
                          media='Photo')
session.set_relationship_bounds(enabled=True,
                                potency_ratio=None,
                                delimit_by_numbers=True,
                                max_followers=30000,
                                max_following=9000,
                                min_followers=50,
                                min_following=5)
session.set_simulation(enabled=False)
session.set_do_like(enabled=True, percentage=100)

session.interact_user_likers(usernames=[]),
random.shuffle(interact_user_likers(usernames),
posts_grab_amount=1-4,
interact_likers_per_post=550,
randomize=True) 

session.set_ignore_users([])
session.set_do_comment(enabled=False, percentage=35)
session.set_ignore_if_contains(['death', 'RIP', 'sad', 'rain', 'depression', 'memorials', 'deaths', 'accidents'])
session.set_action_delays(enabled=True, like=40)

# activity
interact_user_followers([],
random.shuffle(interact_user_followers),
amount=340)
jarrodnorwell commented 1 year ago

Hey @rogersillyface, sorry for the delay. InstaPy2 is not a 1:1 copy of InstaPy meaning any template from their quickstart folder likely won't work. I don't know the usage stats of my tool but if enough people want I'll spend some time to make working quickstart examples.

rogersillyface commented 1 year ago

Hey @official-antique ! Yeah I ralised that, I did try a while ago (and again after reading that somebody had used an old script).

The script in the documentation, which is what i was referencing at the begining with the line one issue, doesn't appear to work either. I don't know what i could have done wrong.

For reference it is thus script:

from instapy2 import InstaPy2 from instapy2.types import CommentType

create a new session

session = InstaPy2()

login to your account

session.login(username='', password='')

this will ask you to select a place

pk = session.configuration.location.get_pk(query='place name here')

enables commenting

session.configuration.comments.set_enabled(enable=True)

set the list of comments to use

session.configuration.comments.set_comments(comments=[ 'wow', # this is a normal comment 'wow :thumbsup:', # this is a comment with an emoji 'wow {}', # this is a comment tagging the user ])

0-100, higher means higher change of commenting (per media)

session.configuration.comments.set_percentage(percentage=100)

this will comment on 10 media from the pk above

session.comment(amount=10, iterable=[pk], type=CommentType.Locations)

Again, for reference, the error is:

Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/instapy2/Instapy2-Comments.py", line 1, in from instapy2 import InstaPy2 File "/usr/local/lib/python3.9/site-packages/instapy2/instapy2.py", line 1, in from .utilities import LoggerConstants, Utility ImportError: attempted relative import with no known parent package

Thanks very much for getting this off the ground!

rogersillyface commented 1 year ago

Hey @official-antique,

Stupid question.. The Quickstart references LoggerConstants here in Terminal:

.utilities import LoggerConstants, Utility

BUt there is no file called LoggerConstants?

Just something I noticed and thought I'd ask.

EDIT: No rush.