python AttributeError: module 'socks' has no attribute 'setdefaultproxy'
Question:
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())
Answers:
Try:
socks.set_default_proxy(----)
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
Do not name the file socks.py….
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())
Try:
socks.set_default_proxy(----)
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
Do not name the file socks.py….