1

I have written a small script in Python and executing it on Windows is fine. I got no errors. In Windows my Python version is 3.5.

I have tried to execute the same program on Ubuntu, Python 3.4 but, but I am getting the following error:

Traceback (most recent call last):
  File "urlscript.py", line 356, in <module>
    postcheck[dc]()
  File "urlscript.py", line 17, in DC8Prod
    pmlogin(url,payload)
  File "urlscript.py", line 254, in pmlogin
    mainpage=requests.get(url,payload)
TypeError: get() takes 1 positional argument but 2 were given
5
  • Watch at get() function. You gave his 2 arguments, but he wants only one. Commented May 6, 2016 at 10:46
  • What version of requests is installed on Ubuntu, what version on Windows? If payload is a dictionary with query parameters, query=payload instead of a positional argument. Commented May 6, 2016 at 10:47
  • @valex But I didnt get any issues with windows Commented May 6, 2016 at 10:48
  • @MartijnPieters I am not sure of version but I pulled with pip3 Commented May 6, 2016 at 10:49
  • @Raja: pip3 freeze will show you the versions of all your packages installed. Commented May 6, 2016 at 10:52

1 Answer 1

3

Only url is really supported as a positional argument; for a GET request with query parameters, use params as the keyword argument:

mainpage = requests.get(url, params=payload)

See Passing Parameters In URLs.

A recent release of requests (2.7.0 or newer), made params an explicit argument to the requests.get() function, making it possible to use it as a positional parameter too. Your version on Ubuntu must be older than that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.