I'm trying to install the ibm_db
python package in a corporate network behind our proxy server. 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:
$ 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. An older issue from 2018 recommends to download it manually and set IBM_DB_HOME
as env variable, which seems worked for him.
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>
. 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:
Extract it
In the extracted archive, open setup.py
and open setup.py
Before PACKAGE = 'ibm_db'
, insert the following lines, where 127.0.0.1:3128
is your proxy server:
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']
Install the package with the manipulated setup.py
file:
$ 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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.