Racking my brain over this. Just signed up here because I was having so much trouble with this. Here is my super simple code:
from jira.client import JIRA
jira_user='username'
jira_pass='password'
jira_server='https://jira-01:8443'
jira_options = {'server': jira_server, 'verify': False}
jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_pass))
When executing, I get this:
Traceback (most recent call last):
File "jira1.py", line 12, in <module>
jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_pass))
File "/usr/lib/python2.6/site-packages/jira/client.py", line 219, in __init__
si = self.server_info()
File "/usr/lib/python2.6/site-packages/jira/client.py", line 1504, in server_info
return self._get_json('serverInfo')
File "/usr/lib/python2.6/site-packages/jira/client.py", line 1894, in _get_json
r = self._session.get(url, params=params)
File "/usr/lib/python2.6/site-packages/jira/resilientsession.py", line 78, in get
return self.__verb('GET', url, **kwargs)
File "/usr/lib/python2.6/site-packages/jira/resilientsession.py", line 63, in __verb
r = method(url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
conn.connect()
File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/usr/lib/python2.6/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 279, in ssl_wrap_socket
cnx.set_tlsext_host_name(server_hostname)
AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
The same thing happens if I remove 'verify': False
I know I can access the API and this user has permissions because I can hit it correctly with curl and get the right results.
Any help is appreciated.
Resolved by reinstalling python-requests via yum.
Related
I have facing some issue with python requests in a Django project. It only occur in 2nd requests.post().
Although It exited with exception TypeError: getresponse() got an unexpected keyword argument 'buffering'.
But after updating urllib3. There is no exception in traceback.
[2021-12-08 15:54:48 +0000] [11410] [CRITICAL] WORKER TIMEOUT (pid:11439)
Traceback (most recent call last):
File "/home/ubuntu/projects/project/api/views/a_view.py", line 765, in create_power_trace
headers=power_trace_headers)
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.7/http/client.py", line 1373, in getresponse
response.begin()
File "/usr/local/lib/python3.7/http/client.py", line 319, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.7/http/client.py", line 280, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "/home/ubuntu/projects/venv/lib/python3.7/site-packages/gunicorn/workers/base.py", line 201, in handle_abort
sys.exit(1)
SystemExit: 1
For your information, my code is something like this:-
res1 = requests.post(url1, data=data1)
result = res1.json()
print(result['id']) # successfully prints
data2 = {'id': result['id']}
res2 = requests.post(url2, data=data2) # System exited
print(res2)
Above snippet works fine outside of my project (tested in a different script with same environment same instance).
And of course, no issue found in local.
Actually the issue was not caused by python or django.
Request lost for Nginx misconfiguration. I think my request hit the destination but reponse cannot came back to source as I forgot to add server_name in nginx conf.
Code is working fine in atom editor, I wanted to know how I can resolve this issue with PyCharm.
import requests
response = requests.get('https://api.github.com/')
print(response.url)
# print status code
print(response.status_code)`
#####################################
ERROR
####################################
1
Traceback (most recent call last):
File "C:\Users\kgowa\PycharmProjects\pythonProject\cs330\7767.py", line 5, in <module>
response = requests.get('https://api.github.com/')
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\requests\adapters.py", line 412, in send
conn = self.get_connection(request.url, proxies)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\requests\adapters.py", line 315, in get_connection
conn = self.poolmanager.connection_from_url(url)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\urllib3\poolmanager.py", line 298, in connection_from_url
return self.connection_from_host(
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\urllib3\poolmanager.py", line 245, in connection_from_host
return self.connection_from_context(request_context)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\urllib3\poolmanager.py", line 260, in connection_from_context
return self.connection_from_pool_key(pool_key, request_context=request_context)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\urllib3\poolmanager.py", line 281, in connection_from_pool_key
pool = self._new_pool(scheme, host, port, request_context=request_context)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\urllib3\poolmanager.py", line 213, in _new_pool
return pool_cls(host, port, **request_context)
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\urllib3\connectionpool.py", line 906, in __init__
HTTPConnectionPool.__init__(
File "C:\Users\kgowa\PycharmProjects\pythonProject\venv\lib\site-packages\urllib3\connectionpool.py", line 197, in __init__
self.pool = self.QueueCls(maxsize)
TypeError: __init__() takes 1 positional argument but 2 were given
Process finished with exit code 1
Trying to get Firebase set up and this code produces the error. I've also tried making the restful call simply using requests and I'm getting the exact same error. I'm using python 3.4. What's going on here?
from firebase import firebase
firebase = firebase.FirebaseApplication('https://testDB-72927.firebaseio.com/', authentication=None)
result = firebase.get('/test', None)
print(result)
Traceback (most recent call last):
File "/Users/Parthenon/Desktop/TestProject/Test.py", line 19, in <module>
firstFunc(mylist)
File "/Users/Parthenon/Desktop/TestProject/Test.py", line 14, in firstFunc
result = firebase.get('/test', None)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/firebase/decorators.py", line 19, in wrapped
return f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/firebase/firebase.py", line 274, in get
return make_get_request(endpoint, params, headers, connection=connection)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/firebase/decorators.py", line 19, in wrapped
return f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/firebase/firebase.py", line 38, in make_get_request
response = connection.get(url, params=params, headers=headers, timeout=timeout)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 310, in get
return self.request('GET', url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 279, in request
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 374, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/adapters.py", line 174, in send
timeout=timeout
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 417, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 232, in _get_conn
return conn or self._new_conn()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 547, in _new_conn
strict=self.strict)
TypeError: __init__() got an unexpected keyword argument 'strict'
My requests module was not up to date.
sudo pip install requests --upgrade
I copy pasted a code from another post which for them, seems fine but mine prints an error and I don't know why... How to make urllib2 requests through Tor in Python?
Anyone can help me with this error?
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9150)
socket.socket = socks.socksocket
import urllib.request
print(urllib.request.urlopen('http://www.google.com').read())
Traceback (most recent call last):
File "/Users/Raphael/Desktop/whatsmyip.py", line 17, in <module>
r = requests.get("http://checkip.dyn.com")
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 68, in get
return request('get', url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 349, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1088, in request
self._send_request(method, url, body, headers)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1126, in _send_request
self.endheaders(body)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1084, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 922, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 857, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 155, in connect
conn = self._new_conn()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 134, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 78, in create_connection
sock.connect(sa)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socks.py", line 369, in connect
self.__negotiatesocks5(destpair[0],destpair[1])
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socks.py", line 176, in __negotiatesocks5
self.sendall("\x05\x01\x00")
TypeError: 'str' does not support the buffer interface
and do anyone know why? I would really like to use this module but it doesn't work!
when I make a GET call using requests module I get this error AttributeError: set_default_verify_paths. I am using python 2.6.9 version. when I use cURL command, I get the proper output. Its just not happening in python program. Am I missing any configuration setting/ package.
here is the traceback:
File "<string>", line 1, in <module>
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
conn.connect()
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/usr/local/lib64/python2.6/site-packages/requests-2.7.0-py2.6.egg/requests/packages/urllib3/contrib/pyopenssl.py", line 269, in ssl_wrap_socket
ctx.set_default_verify_paths()
AttributeError: set_default_verify_paths