Python 通过Tor连接时SocksiPy失败

Python 通过Tor连接时SocksiPy失败,python,urllib2,socks,tor,httplib,Python,Urllib2,Socks,Tor,Httplib,尝试了以下3种方法来控制Tor: 使用TorCtl/urllib2: 使用socks/httplib: 使用socks/urllib2: 它们中的每一个都失败,但有相同的错误(试图尽可能清楚地说明): 有人知道它来自哪里吗?看起来您正在使用SocksiPy库。我也有同样的问题,并通过直接从安装此库来修复。我第一次通过pip安装它时 对我来说,它实际上失败了socksipy分支安装了pip 但是,在我直接将socks.py下载到我的工作目录后,它运行正常。没有人知道那里发生了什么事?只是试图通

尝试了以下3种方法来控制Tor:

  • 使用TorCtl/urllib2:
  • 使用socks/httplib:
  • 使用socks/urllib2:
它们中的每一个都失败,但有相同的错误(试图尽可能清楚地说明):


有人知道它来自哪里吗?

看起来您正在使用SocksiPy库。我也有同样的问题,并通过直接从安装此库来修复。我第一次通过
pip
安装它时

对我来说,它实际上失败了
socksipy分支
安装了pip


但是,在我直接将socks.py下载到我的工作目录后,它运行正常。

没有人知道那里发生了什么事?只是试图通过setup.py直接从tar.gz安装它,它仍然以同样的方式崩溃。
Traceback (most recent call last):

File "tor.py", line 26, in <module>
  print(urllib2.urlopen("http://www.ifconfig.me/ip").read())

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py"
line 127, in urlopen
  return _opener.open(url, data, timeout)
line 404, in open
  response = self._open(req, data)
line 422, in _open
  '_open', req)
line 382, in _call_chain
  result = func(*args)
line 1214, in http_open
  return self.do_open(httplib.HTTPConnection, req)
line 1181, in do_open
  h.request(req.get_method(), req.get_selector(), req.data, headers)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py"
line 973, in request
  self._send_request(method, url, body, headers)
line 1007, in _send_request
  self.endheaders(body)
line 969, in endheaders
  self._send_output(message_body)
line 829, in _send_output
  self.send(msg)
line 791, in send
  self.connect()
line 772, in connect
  self.timeout, self.source_address)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py"
line 562, in create_connection
  sock.connect(sa)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SocksiPy_branch-1.01-py2.7.egg/socks.py"
line 392, in connect
  self.__negotiatesocks5(destpair[0],destpair[1])
line 199, in __negotiatesocks5
  self.sendall("\x05\x01\x00")
line 165, in sendall
  socket.socket.sendall(self, bytes)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SocksiPy_branch-1.01-py2.7.egg/socks.py", line 163, in sendall
  if 'encode' in dir(bytes):
RuntimeError: maximum recursion depth exceeded while calling a Python object