简体   繁体   English

在公司代理后面安装 ibm_db 时 Errno 111 Connection denied (DB2 with Python3)

[英]Errno 111 Connection refused when installing ibm_db behind corporate proxy (DB2 with Python3)

I'm trying to install the ibm_db python package in a corporate network behind our proxy server.我正在尝试在我们的代理服务器后面的公司网络中安装ibm_db python package Even with the --proxy switch (which is a local squid connecting to the corporate proxy in my case) I get ean error cause the package seems to download dependencies by executing python code:即使使用--proxy开关(在我的情况下,这是连接到公司代理的本地 squid),我也会收到 ean 错误,导致 package 似乎通过执行 python 代码下载依赖项:

$ pip3 install --proxy "http://127.0.0.1:3128" ibm_db
Collecting ibm_db
  Using cached ibm_db-3.0.3.tar.gz (794 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cd295_i4/ibm-db/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cd295_i4/ibm-db/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-cd295_i4/ibm-db/pip-egg-info
         cwd: /tmp/pip-install-cd295_i4/ibm-db/
    Complete output (44 lines):
    Detected 64-bit Python
    Downloading https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz
    Traceback (most recent call last):
      File "/usr/lib/python3.8/urllib/request.py", line 1350, in do_open
        h.request(req.get_method(), req.selector, req.data, headers,
      File "/usr/lib/python3.8/http/client.py", line 1255, in request
        self._send_request(method, url, body, headers, encode_chunked)
      File "/usr/lib/python3.8/http/client.py", line 1301, in _send_request
        self.endheaders(body, encode_chunked=encode_chunked)
      File "/usr/lib/python3.8/http/client.py", line 1250, in endheaders
        self._send_output(message_body, encode_chunked=encode_chunked)
      File "/usr/lib/python3.8/http/client.py", line 1010, in _send_output
        self.send(msg)
      File "/usr/lib/python3.8/http/client.py", line 950, in send
        self.connect()
      File "/usr/lib/python3.8/http/client.py", line 1417, in connect
        super().connect()
      File "/usr/lib/python3.8/http/client.py", line 921, in connect
        self.sock = self._create_connection(
      File "/usr/lib/python3.8/socket.py", line 808, in create_connection
        raise err
      File "/usr/lib/python3.8/socket.py", line 796, in create_connection
        sock.connect(sa)
    ConnectionRefusedError: [Errno 111] Connection refused

I guess the the proxy switch doesn't get forwarded to the python call inside.我猜proxy开关不会被转发到内部的 python 调用。 An older issue from 2018 recommends to download it manually and set IBM_DB_HOME as env variable, which seems worked for him. 2018 年的一个较旧问题建议手动下载它并将IBM_DB_HOME设置为 env 变量,这似乎对他有用。

export IBM_DB_HOME=/home/myuser/Downloads/db2_py/

Now I got another error:现在我得到另一个错误:

$ pip3 install --proxy "http://127.0.0.1:3128" ibm_db
Collecting ibm_db
  Using cached ibm_db-3.0.3.tar.gz (794 kB)
ERROR: Files/directories not found in /tmp/pip-install-a0t600_t/ibm-db/pip-egg-info

Seems like there are some additional files required.好像还需要一些额外的文件。 I also tried to download the archive from pypi.org and install it using pip3 install <path-to-downloaded-archive> .我还尝试从 pypi.org 下载存档并使用pip3 install <path-to-downloaded-archive>安装它。 But this doesn't help, since the dependencies are not included there.但这无济于事,因为那里不包含依赖项。

I haven't found a real solution yet, but a workaround to get the package installed:我还没有找到真正的解决方案,但是安装了 package 的解决方法:

  1. Download the python package from pypi.org从 pypi.org 下载 python package

  2. Extract it提取它

  3. In the extracted archive, open setup.py and open setup.py在提取的存档中,打开setup.py并打开setup.py

  4. Before PACKAGE = 'ibm_db' , insert the following lines, where 127.0.0.1:3128 is your proxy server:PACKAGE = 'ibm_db'之前,插入以下行,其中127.0.0.1:3128是您的代理服务器:

     os.environ['http_proxy'] = 'http://127.0.0.1:3128/' os.environ['https_proxy'] = os.environ['http_proxy'] os.environ['HTTP_PROXY'] = os.environ['http_proxy'] os.environ['HTTPS_PROXY'] = os.environ['http_proxy']
  5. Install the package with the manipulated setup.py file:使用操纵的setup.py文件安装 package:

     $ pip3 install --proxy "http://127.0.0.1:3128" /home/myuser/Downloads/ibm_db2_extracted/ibm_db-3.0.3/

Now the installation works, cause the proxy is set for the entire python environment instead of just pip.现在安装工作正常,因为为整个 python 环境设置了代理,而不仅仅是 pip。 However, this is not an optimal solution because we have to apply this workaround on every update, but a suiteable short-term solution until we find something better.但是,这不是最佳解决方案,因为我们必须在每次更新时都应用此解决方法,而是一个合适的短期解决方案,直到我们找到更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM