requests.exceptions.InvalidSchema: Missing dependencies for SOCKS support.

Created on 17 Aug 2016  ·  7Comments  ·  Source: psf/requests

Hi list
i got problem Missing dependencies for SOCKS support. with requests module version 2.11,

but with requests module version 2.10 the requests module works fine

my enviroment :
declare -x VIRTUAL_ENV="/home/hadn/python3"
declare -x VTE_VERSION="3803"
declare -x WINDOWID="33554439"
declare -x WINDOWPATH="1"
declare -x XAUTHORITY="/run/gdm/auth-for-hadn-0O4FTR/database"
declare -x XDG_CURRENT_DESKTOP="GNOME-Classic:GNOME"
declare -x XDG_MENU_PREFIX="gnome-"
declare -x XDG_RUNTIME_DIR="/run/user/1000"
declare -x XDG_SEAT="seat0"
declare -x XDG_SESSION_DESKTOP="gnome-classic"
declare -x XDG_SESSION_ID="2"
declare -x XDG_VTNR="1"
declare -x XMODIFIERS="@im=ibus"
declare -x _system_arch="x86_64"
declare -x _system_name="CentOS"
declare -x _system_type="Linux"
declare -x _system_version="7"
declare -x all_proxy="socks://proxy.hcm.fpt.vn:80/"
declare -x ftp_proxy="http://proxy.hcm.fpt.vn:80/"
declare -x http_proxy="http://proxy.hcm.fpt.vn:80/"
declare -x https_proxy="http://proxy.hcm.fpt.vn:80/"

(python3)[hadn@rad-hadn4 ~]$ /home/hadn/Laravel/learning_bootstrap_v4/film/film_le.sh
Traceback (most recent call last):
File "/home/hadn/Laravel/learning_bootstrap_v4/film/film_le_crawler_page_1.py", line 24, in
html_content = session.get(url)
File "/home/hadn/python3/lib/python3.4/site-packages/requests/sessions.py", line 483, in get
return self.request('GET', url, *_kwargs)
File "/home/hadn/python3/lib/python3.4/site-packages/requests/sessions.py", line 471, in request
resp = self.send(prep, *_send_kwargs)
File "/home/hadn/python3/lib/python3.4/site-packages/requests/sessions.py", line 581, in send
r = adapter.send(request, *_kwargs)
File "/home/hadn/python3/lib/python3.4/site-packages/requests/adapters.py", line 384, in send
conn = self.get_connection(request.url, proxies)
File "/home/hadn/python3/lib/python3.4/site-packages/requests/adapters.py", line 287, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "/home/hadn/python3/lib/python3.4/site-packages/requests/adapters.py", line 183, in proxy_manager_for
*_proxy_kwargs
File "/home/hadn/python3/lib/python3.4/site-packages/requests/adapters.py", line 43, in SOCKSProxyManager
raise InvalidSchema("Missing dependencies for SOCKS support.")
requests.exceptions.InvalidSchema: Missing dependencies for SOCKS support.

Most helpful comment

$ pip install requests[socks]

All 7 comments

$ pip install requests[socks]

The specific problem here is that in 2.11 we started supporting all_proxy, which you have set up as a SOCKS proxy. That means we'd attempt to use the SOCKS proxy and fail.

@Lukasa @kennethreitz can i have option to disable the SOCKS proxy???

@alochym01 If you don't want it, why is it set in your environment? Regardless, if you use a session with trust_env=False that problem will no longer occur, though you'll lose your environment HTTP proxy.

However, there does seem like there is a bug here: requests will prefer all_proxy to a scheme-specific proxy. I think that's a bad idea. @sigmavirus24, should we re-order that?

@Lukasa So as I understand it, all_proxy is what should be used if http(s)_proxy is unset. And in a more general sense it should be used if <protocol>_proxy is unset. So based on that understanding (and assuming I'm correct) yes we definitely should re-order that. Let's file a new bug for that.

@alochym01 Another option seems to be to use proxies={'all': None}.

@Lukasa proxies={'all': None} not work because the network should go through proxy, so i see you did open the new issue :)
let follow the new issue :+1:

Was this page helpful?
0 / 5 - 0 ratings