gevent
을 사용할 때 requests
을 사용할 수 없습니다. 내 사용법이 잘못 되었습니까?python3 글로벌 이름 'SOL_SOCKET이 정의되지 않았습니다.
from gevent import monkey; monkey.patch_all()
import gevent, requests
requests.get('https://haofly.net')
는 오류 인상 : 나는 monkey.patch_all()
에 ssl=False
을 추가하는 경우
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 595, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 352, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 831, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connection.py", line 289, in connect
ssl_version=resolved_ssl_version)
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/util/ssl_.py", line 308, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/local/lib/python3.3/site-packages/gevent/_ssl3.py", line 60, in wrap_socket
_context=self)
File "/usr/local/lib/python3.3/site-packages/gevent/_ssl3.py", line 143, in __init__
if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
NameError: global name 'SOL_SOCKET' is not defined
내 파이썬의 버전은 3.3
입니다, 그것은 반환
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.3/site-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 595, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 352, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 831, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/connection.py", line 289, in connect
ssl_version=resolved_ssl_version)
File "/usr/local/lib/python3.3/site-packages/requests/packages/urllib3/util/ssl_.py", line 308, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/local/lib/python3.3/ssl.py", line 245, in wrap_socket
_context=self)
File "/usr/local/lib/python3.3/ssl.py", line 335, in __init__
server_hostname)
TypeError: _wrap_socket() argument 1 must be _socket.socket, not SSLSocket
흥미 롭습니다. 그 이름은'ssl' 모듈에서 발견되어 져야합니다. Python 3.3이 지원되는 것을 본다. openssl의 어떤 버전을 설치 했습니까? –
@MartijnPieters \t 당신은 리눅스 패키지 openssl을 의미합니까? 내 openssl은 openssl-1.0.1e-48.el6_8.1.x86_64, CentOS 6.8 – haofly
입니다. 설치 과정에서'from ssl import SOL_SOCKET'이 실패한 것 같습니다. 왜 그게 내가 완전히 이해하지 못하는지. 어딘가에 그림자'ssl' 모듈이 있을까요? 'import ssl; print (ssl .__ file __)'은 시스템 위치를 출력해야합니다. –