简体   繁体   中英

Can't create a bot with Tweepy in Python. Traceback (most recent call last) Error appears

I wanted to create a twitter bot just to test things out.

I wrote this code:

auth = tweepy.OAuthHandler(api_key, api_key_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth, wait_on_rate_limit=True)

api.create_friendship("******")

(Obviously I also created variables like api_key = "...")

But the only message I get out of the console ist:

Traceback (most recent call last):
  File "C:\Users\Anwender\PycharmProjects\TwitterBot\main.py", line 13, in <module>
    api.create_friendship("******")
  File "C:\Users\Anwender\PycharmProjects\TwitterBot\venv\lib\site-packages\tweepy\api.py", line 46, in wrapper
    return method(*args, **kwargs)
TypeError: API.create_friendship() takes 1 positional argument but 2 were given

Can someone tell me whats wrong? Tweepy is installed. Had a few problems until i installed in in PyCharm itself instead of cmd.

When I first installed tweepy I upgraded pip to the latest version. Don't know if this is the problem here.

It's likely due to the lack of keyword arguments in create_friendship() .

You'll need to identify whichever argument you're passing. For example, if "*****" is the user id, then:

api.create_friendship(user_id = "******")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM