Python's requests “Missing dependencies for SOCKS support” when using SOCKS5 from Terminal

后端 未结 14 917
南笙
南笙 2020-12-12 20:36

I\'m trying to interact with an API from my Python 2.7 shell using a package that relies on Python\'s requests. Thing is the remote address is blocked by my network (univers

14条回答
  •  囚心锁ツ
    2020-12-12 21:19

    Got the same error after a reported issue that pysocks would not be pulled by the requests[socks]>=0.23.0 requirement.

    I could (esoterically) fix it by removing the requests>=0.23.0 requirement i also had in the same requirements.txt.

    Running Python3.7 on Debian, and the user who reported the bug is running python3.6 on Ubuntu.

    Before the patch

    $ cat requirements.txt 
    requests>=2.23.0
    requests[socks]>=2.23.0
    $ python3 -m venv venv
    $ . venv/bin/activate
    (venv) $ pip --no-cache-dir install -r requirements.txt
    Collecting requests>=2.23.0 (from -r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl (61kB)
        100% |████████████████████████████████| 71kB 202kB/s 
    Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/9f/f0/a391d1463ebb1b233795cabfc0ef38d3db4442339de68f847026199e69d7/urllib3-1.25.10-py2.py3-none-any.whl (127kB)
        100% |████████████████████████████████| 133kB 617kB/s 
    Collecting idna<3,>=2.5 (from requests>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl (58kB)
        100% |████████████████████████████████| 61kB 2.8MB/s 
    Collecting chardet<4,>=3.0.2 (from requests>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
        100% |████████████████████████████████| 143kB 10.4MB/s 
    Collecting certifi>=2017.4.17 (from requests>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/5e/c4/6c4fe722df5343c33226f0b4e0bb042e4dc13483228b4718baf286f86d87/certifi-2020.6.20-py2.py3-none-any.whl (156kB)
        100% |████████████████████████████████| 163kB 4.7MB/s 
    Installing collected packages: urllib3, idna, chardet, certifi, requests
    Successfully installed certifi-2020.6.20 chardet-3.0.4 idna-2.10 requests-2.24.0 urllib3-1.25.10
    

    After the patch

    Now applying the following patch:

    diff --git a/sauron/requirements.txt b/sauron/requirements.txt
    index a0c901b..f38d18f 100644
    --- a/sauron/requirements.txt
    +++ b/sauron/requirements.txt
    @@ -1,2 +1 @@
    -requests>=2.23.0
     requests[socks]>=2.23.0
    
    $ cat requirements.txt 
    requests[socks]>=2.23.0
    $ cat requirements.txt 
    requests[socks]>=2.23.0
    (venv) $ pip --no-cache-dir install -r requirements.txt 
    Collecting requests[socks]>=2.23.0 (from -r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/45/1e/0c169c6a5381e241ba7404532c16a21d86ab872c9bed8bdcd4c423954103/requests-2.24.0-py2.py3-none-any.whl (61kB)
        100% |████████████████████████████████| 71kB 234kB/s 
    Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests[socks]>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/9f/f0/a391d1463ebb1b233795cabfc0ef38d3db4442339de68f847026199e69d7/urllib3-1.25.10-py2.py3-none-any.whl (127kB)
        100% |████████████████████████████████| 133kB 678kB/s 
    Collecting chardet<4,>=3.0.2 (from requests[socks]>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
        100% |████████████████████████████████| 143kB 2.3MB/s 
    Collecting idna<3,>=2.5 (from requests[socks]>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl (58kB)
        100% |████████████████████████████████| 61kB 6.2MB/s 
    Collecting certifi>=2017.4.17 (from requests[socks]>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/5e/c4/6c4fe722df5343c33226f0b4e0bb042e4dc13483228b4718baf286f86d87/certifi-2020.6.20-py2.py3-none-any.whl (156kB)
        100% |████████████████████████████████| 163kB 4.8MB/s 
    Collecting PySocks!=1.5.7,>=1.5.6; extra == "socks" (from requests[socks]>=2.23.0->-r requirements.txt (line 1))
      Downloading https://files.pythonhosted.org/packages/8d/59/b4572118e098ac8e46e399a1dd0f2d85403ce8bbaad9ec79373ed6badaf9/PySocks-1.7.1-py3-none-any.whl
    Installing collected packages: urllib3, chardet, idna, certifi, PySocks, requests
    Successfully installed PySocks-1.7.1 certifi-2020.6.20 chardet-3.0.4 idna-2.10 requests-2.24.0 urllib3-1.25.10
    

    Pysocks was effectively pulled.

提交回复
热议问题