Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request() got an unexpected keyword argument 'json' #61

Closed
igorsantos07 opened this issue Jan 25, 2016 · 4 comments
Closed

request() got an unexpected keyword argument 'json' #61

igorsantos07 opened this issue Jan 25, 2016 · 4 comments

Comments

@igorsantos07
Copy link

Running with -n works fine, but when I remove the option I get the following after entering the GitHub password:

Traceback (most recent call last):
  File "migrate.py", line 442, in <module>
    sys.exit(main(options))
  File "migrate.py", line 131, in main
    gh_issue, gh_comments, options.github_repo, gh_auth, headers
  File "migrate.py", line 385, in push_github_issue
    respo = requests.post(url, json=issue_data, auth=auth, headers=headers)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 88, in post
    return request('post', url, data=data, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'json'
@jeffwidman
Copy link
Owner

What version of requests are you using? POST'ing using the json kwarg requires >=2.4.2 http://requests.readthedocs.org/en/latest/user/quickstart/#more-complicated-post-requests

@igorsantos07
Copy link
Author

Can I answer "I have no idea"? haha
Fiddling over the installed source code I see I have 2.2.1.

I know nothing about python, but or pip, but... is it possible for you to force a specific minimal version on the requirements.pip file?

I am not able to update it through pip, as its apt-get package is used by the ubuntu-desktop itself x___x
I'm going to look around Google to see what I can find...

$ sudo pip3 install --upgrade requests
[sudo] password for igoru: 
Downloading/unpacking requests from https://pypi.python.org/packages/2.7/r/requests/requests-2.9.1-py2.py3-none-any.whl#md5=58a444aaa02780ad01983f5f540e67b2
  Downloading requests-2.9.1-py2.py3-none-any.whl (501kB): 501kB downloaded
Installing collected packages: requests
  Found existing installation: requests 2.2.1
    Not uninstalling requests at /usr/lib/python3/dist-packages, owned by OS
Successfully installed requests
Cleaning up...

@jeffwidman
Copy link
Owner

Good call, I will update the requirements with minimum version.

In the meantime, I suggest using a python3 venv as documented on the readme... it'll let you pip install local lib versions to a specific virtualenv without conflicting with global OS versions. Then once you're done using the script, just delete the venv you created.

@igorsantos07
Copy link
Author

Okay, my bad. I had no idea what those two commands should do in the README, and went without them. I guess they would save me from having dependency issues with my OS environment, right? There was no pyvenv command in my machine, so I simply skipped that.

Maybe you could try making the README more python-noob-friendly? I know little (nothing?) about python or venvs, and got lost on that. I got it working through this answer, installing the python-virtualenv package:

virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install package-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants