ChaoticTwist ChaoticTwist - 4 months ago 27
Python Question

Requests: Module works locally but failed on pythonanywhere

I am trying to make a twitter bot that uses requests library to get data from nytimes api.

There is a line in the code

resp = requests.get(API_ENDPOINT, my_params)

Now this works very well when I run it locally. So I uploaded it to pythonanywhere. The moment I tried to run it I got this error:

resp = requests.get(API_ENDPOINT, my_params)

TypeError: get() takes exactly 1 argument (2 given)

What is happening? I have started using requests as well as pythonanywhere recently. So I have literally no idea where to start debugging.


You have different requests versions installed on PythonAnywhere and locally.

From what I see requests version installed on PythonAnywhere is 2.4.0. At that point, you had to specify params keyword argument explicitly:

requests.get(url, **kwargs)

And you have to write:

resp = requests.get(API_ENDPOINT, params=my_params)

In the most recent version (2.10.0 at the moment), you can have params specified as a positional argument:

requests.get(url, params=None, **kwargs)

resp = requests.get(API_ENDPOINT, my_params)