Cannot pip install via proxy when on Conda env - python

I have some weird problem with pip install via proxy.
When I'm in the base Conda environment (/conda) pip install works fine (using proxy: HTTPS_PROXY env variable).
But when I'm switching to another Conda environment, I get proxy errors:
$ conda activate /User/bryan_env
$ pip install xmltodict
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/xmltodict/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/xmltodict/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/xmltodict/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/xmltodict/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /simple/xmltodict/
ERROR: Could not find a version that satisfies the requirement xmltodict
ERROR: No matching distribution found for xmltodict
I've tried to use .condarc as well but had the same errors.
Important to say that this is all in Jupyter shell running in Kuberenetes pod.
Any idea what am I doing wrong here?

I had the same issue and it was solved by reinstalling pip in the environment using:
conda install -c anaconda pip
After that, try your pip install. It worked for me.

Related

Pip install commands don't work until they have exhausted all timeouts, after which they work normally

Earlier today my pip started exhibiting this very strange behavior where any pip install command timouts 5 times before the download starts. This is unaffected by the --default-timeout flag. For instance, doing pip install pandas I get
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(\<pip.\_vendor.urllib3.connection.HTTPConnection object at 0x7ff4b60badc0\>, 'Connection to pypi.cogtree.com timed out. (connect timeout=1.0)')': /cogtree/simple/pandas/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(\<pip.\_vendor.urllib3.connection.HTTPConnection object at 0x7ff4b60c7040\>, 'Connection to pypi.cogtree.com timed out. (connect timeout=1.0)')': /cogtree/simple/pandas/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(\<pip.\_vendor.urllib3.connection.HTTPConnection object at 0x7ff4b60c7250\>, 'Connection to pypi.cogtree.com timed out. (connect timeout=1.0)')': /cogtree/simple/pandas/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(\<pip.\_vendor.urllib3.connection.HTTPConnection object at 0x7ff4b60c7460\>, 'Connection to pypi.cogtree.com timed out. (connect timeout=1.0)')': /cogtree/simple/pandas/
Collecting pandas
Downloading pandas-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl (11.4 MB)
|████████████████████████████████| 11.4 MB 6.9 MB/s
We would get the same exact result with connect timeout=10
I'm on
pip 21.2.4,
Python 3.8.8,
macOS 11.5.1,
and this is happening inside of a anaconda 4.11.0 virtual env with only default conda packages installed.
I've tried uninstalling and reinstalling pip, and conda. I can ping pypi.org fine. I tried this only multiple different wifi. Closing and reopening the terminal did not affect it either.

Why am I getting SSL issues inside docker with pip

I am facing issues lately with using pip while building a docker image. The base OS is ubuntu 18.04 and the error is as below
python3 -m pip install --upgrade pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:852)'),)': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:852)'),)': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:852)'),)': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:852)'),)': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:852)'),)': /simple/pip/
The same works in host OS with out issues. The docker version is Docker version 19.03.3, build a872fc2f86
Some of the troubeshooting I have done currently.
Adding DNS to /etc/docker/daemon.json
Restarting docker engine
Running with pip --trusted-host pypi.org install -U pip
Adding certificate and updating ca
Inspite of all the troubleshooting the issue still persists. Is there anyother way to get this working.
PS : This just started to happen from yesterday and there were no issues earlier.
try to add the cacert for Ubuntu in your Dockerfile:
RUN wget -P /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/certs/root.crt http://www.cacert.org/certs/class3.crt
RUN update-ca-certificates
if that does not help you may see this question

pip doesn't connect, can't install anything

I'm trying to use pip install on a raspberry pi 4 (Raspian Buster) but I've been getting the same errors for a while now, I've tried a lot of common fixes but none worked.
What I've already tried:
- apt-get update and upgrade
- uninstalled and installed opensll
- uninstalled and installed pip and pip3 several times
- uninstalled and installed python and python3 (with restarts)
- I'm not being blocked by a firewall or anything (I'm using a raspberry pi 4 connected directly to the router at home)
Example outputs, same result with pip/pip3, using sudo and not and also tried using the flag "--default-timeout=120", always get the same errors
$ sudo pip3 install pyopenssl
Collecting pyopenssl
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pyopenssl/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pyopenssl/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pyopenssl/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pyopenssl/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/pyopenssl/
ERROR: Could not find a version that satisfies the requirement pyopenssl (from versions: none)
ERROR: No matching distribution found for pyopenssl
$ sudo pip3 install docker-compose
Collecting docker-compose
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/docker-compose/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/docker-compose/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/docker-compose/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/docker-compose/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/docker-compose/
ERROR: Could not find a version that satisfies the requirement docker-compose (from versions: none)
ERROR: No matching distribution found for docker-compose
Whenever pip has to connect to anything I get this same kind of errors, any ideia as why this is happening?

pip install package via proxy

I tried to pip install using proxy, the proxy setting is correct because it works for npm install . what i tried is as below shown but got error message. any idea will be more than welcome!
set http_proxy=http://<username>:<password>#<proxy_server>:<port>
set https_proxy=https://<username>:<password>#<proxy_server>:<port>
pip install Flask
Collecting Flask
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))': /simple/flask/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))': /simple/flask/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))': /simple/flask/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))': /simple/flask/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))': /simple/flask/
Could not find a version that satisfies the requirement Flask (from versions: )
No matching distribution found for Flask
pip install packageName --proxy proxy_Server:portnumber
ex: pip install numpy --proxy https://myproxy#myserver.com:9090
From https://stackoverflow.com/a/33611028/2653663 it looks like it should be
set https_proxy=<domain><username>:<password>#<proxy_server>:<port>
So port instead of ip.
set http_proxy=... and set https_proxy=.... should be enough if the proxy works.
Please run the following command to make sure that it works:
curl https://google.com

Pip install Proxy with 403 Forbidden inside of a Dockerfile

I am trying to set up a docker container by using a Dockerfile that is inside of a corporate network behind a proxy.
Each time I am trying to execute the installation of different python packages by running the "pip install" command I am facing the following issue:
Step 9/20 : RUN pip install requests
---> Running in 98d679800849
Collecting requests
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',))': /packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',))': /packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',))': /packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',))': /packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',))': /packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))
My current Dockerfile contains the following commands:
# Base image
FROM python:3.6-slim
ENV http_proxy http://user:pw#server:port/
ENV https_proxy http://user:pw#server:port/
ENV HTTP_PROXY http://user:pw#server:port/
ENV HTTPS_PROXY http://user:pw#server:port/
RUN pip install --upgrade pip #thats working
RUN pip install requests #not working
RUN pip --proxy=http://user:pw#server:port/ install pandas #not working either
I tried several solutions like providing the build argument when executing the build command and passing the proxy settings inside for example. I dont have further clues why its not working for the running the pip command.
Thats even more strange since I am able to pull the base image which had not worked before defining the proxysettings by using the ENV variable. Anyone here that has a clue what causes this problem?

Categories

Resources