Have you tried this:
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "socks.proxy.lan", 8080, True)
replace port 8080 with port, and "True" - "True" if you want to enable rdns.
If you are using Python version 3 or higher, I suggest you use PySocks, and that will be
socks.set_default_proxy(socks.PROXY_TYPE_SOCKS5, "socks.proxy.lan", 8080, True)
Flameblazer
source share