halcy / Mastodon.py

Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
MIT License
876 stars 150 forks source link

MastodonVersionError: Version check failed (Need version 3.4.0) #340

Open carolmb opened 1 year ago

carolmb commented 1 year ago

Hello. I've been using the API these days, but since yesterday the following error is occurring and I can't find any record of it.

---> 17 user_profile = api1.account_lookup("{}@{}".format(user_name, user_server))

File d:\Documentos\yy-projects\mastodon-proj.venv\Lib\site-packages\decorator.py:232, in decorate..fun(*args, *kw) 230 if not kwsyntax: 231 args, kw = fix(args, kw, sig) --> 232 return caller(func, (extras + args), **kw)

File d:\Documentos\yy-projects\mastodon-proj.venv\Lib\site-packages\mastodon\utility.py:44, in api_version..api_min_version_decorator..wrapper(function, self, *args, **kwargs) 42 major, minor, patch = parse_version_string(version) 43 if major > self.mastodon_major: ---> 44 raise MastodonVersionError(f"Version check failed (Need version {version})") 45 elif major == self.mastodon_major and minor > self.mastodon_minor: 46 raise MastodonVersionError(f"Version check failed (Need version {version})")

MastodonVersionError: Version check failed (Need version 3.4.0)

Since I'm not familiar with where exactly I should ask about this kind of stuff if there is a better place, let me know. I can delete this one and repost where it is more suitable.

Thank you in advance.

More information: I'm using python (3.11.3) and mastodon.py (1.8.1).

I also asked the same here. I'm not sure if it is a problem from mastodon.py or server side.

andypiper commented 1 year ago

What specific Mastodon instance (server URL) is this happening with? Did it previously work with that instance, or has it never worked with that instance? Has anything changed on your system since the last time the code worked for you?

carolmb commented 1 year ago

When I used the instance for the first time, I was setting the values directly on the code, so it worked with no problems. When I refactored the code then the errors appeared.

I discovered what was wrong but the message error did not help (the one I related previously).

About my mistakes:

I tried two different approaches to initialize a Mastodon object, both were incorrect.

The first problem was how I was reading the file with the cliend_id, cliend_secret, access_token, and api_base_url strings. Once I removed the unnecessary "\n" at the end of the args, it worked well.

The other problem was about giving a filename as an argument to Mastodon init I was trying to use as follows:

api = Mastodon(client_id='filename-with-id-secret-token-url.txt')

based on its documentation _"If a file is given as clientid, client ID, secret and base url are read from that file." Do you know how this argument should be used to work correctly?

In both cases, the error only occurred when I was trying to use the object, for instance, calling api.account_lookup.

halcy commented 1 year ago

Let me actually reopen this - I've noticed myself that the error message can be very misleading, and should be fixed in some way.