BKCapri
BKCapri

Reputation: 558

python AttributeError: module 'socks' has no attribute 'setdefaultproxy'

Trying to test out the socks module but in every case I get an "AttributeError: module 'socks' has no attribute 'setdefaultproxy'"

  import socks
  import socket
  socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)
  socket.socket = socks.socksocket
  import urllib2

  print(urllib2.urlopen("http://www.yahoo.com").read())

Upvotes: 1

Views: 4648

Answers (2)

Wangolo Joel
Wangolo Joel

Reputation: 60

Hey there trying replacing

socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)

with

socks.set_default_proxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)

Note the below.

socks.set_default_proxy

In other words in should be

import socks
import socket
socks.set_default_proxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)
socket.socket = socks.socksocket
import urllib2

print(urllib2.urlopen("http://www.yahoo.com").read())

If it still failes try to check. Which version of socks are you using?, Which version of python are you using?, because I tested it on python 2.7.9, and I don't get your error. Which os are you running?

sock: 1.5.6

https://github.com/Anorov/PySocks

http://socksipy.sourceforge.net/

Upvotes: 2

ᴀʀᴍᴀɴ
ᴀʀᴍᴀɴ

Reputation: 4538

Try:

socks.set_default_proxy(----)

Upvotes: 0

Related Questions