PIP not working - proxy - proxy

python pip is not working behind proxy
I tried
sudo -H pip --proxy https://proxy_ip:proxy_port install <package>
sudo -H pip --proxy https://usename:password#proxy_ip:proxy_port install <package>
sudo easy_install pip
and nothing is working, I also tried setting environment variables HTTP_PROXY but it isn't working.
For instance, here is the error when trying to install toolz:
Collecting toolz
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/toolz/
Could not find a version that satisfies the requirement toolz (from versions: )
No matching distribution found for toolz

I use pip install behind a proxy frequently. Here's the syntax that's working for me:
sudo pip --proxy username:password#ip_address:port install <package_name>

The problem was within a conf file that loads old proxy settings. Also the environment variables are case sensitive. So check if there is a difference between HTTP_PROXY and http_proxy by using printenv in linux
Then as #MedAli suggested: adding --proxy while using pip will work

Related

how to install networkx package on CPython

I have installed CPython [1] on my local machine (macOS Catalina, v. 10.15.4) to speed up computations for function optimize_graph_edit_distance in networkx package. Before, I was running the code on Python3, which takes a lot of time. However, when I run the code with CPython (the alias for CPython is python3), I obtain the following error:
Traceback (most recent call last):
File "/Users/olha/Desktop/GED_optima.py", line 3, in <module>
import networkx as nx
ModuleNotFoundError: No module named 'networkx'
I tried python3 -m pip3 install networkx, but I got the following error:
Defaulting to user installation because normal site-packages is not writeable
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/networkx/
Could not fetch URL https://pypi.org/simple/networkx/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/networkx/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement networkx (from versions: none)
ERROR: No matching distribution found for networkx
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Does anybody knows how to install networkx on CPython?
Thank you!
Olha
[1]: https://github.com/python/cpython#documentation
You can install networkx by:
git clone https://github.com/networkx/networkx.git
cd networkx
sudo python setup.py install
Try running the following command (Copied from Mayur Deshmukh's answer to ssl not available):
python3 -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip

SSL errors while installing python packages from PyPI in a databricks cluster

I am trying to install azure-storage-file-datalake in a databricks cluster, but due to internal dependency I am facing the below SSL error. I am using python 3.7.3, pip 20 and was able to install python packages that don't have any dependency or if the dependencies are already installed by default.
java.lang.RuntimeException: ManagedLibraryInstallFailed: org.apache.spark.SparkException: Process List(/databricks/python/bin/pip, install, azure-storage-file-datalake, --disable-pip-version-check) exited with code 1. Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')"))': /simple/azure-storage-file-datalake/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')"))': /simple/azure-storage-file-datalake/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')"))': /simple/azure-storage-file-datalake/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')"))': /simple/azure-storage-file-datalake/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')"))': /simple/azure-storage-file-datalake/ Could not find a version that satisfies the requirement azure-storage-file-datalake (from versions: ) No matching distribution found for azure-storage-file-datalake for library:PythonPyPiPkgId(azure-storage-file-datalake,None,None,List()),isSharedLibrary=false
You can try to install "azure-storage-file-datalake" using Install Library option.
Here are the steps to install libraries using Library.
In an org level setup, have to open ports (outside of VNet) and ACL's, needs HSEC approvals.

Docker-compose, pip install -r requirements.txt' returned a non-zero code: 1

I am kind of new with docker-compose. Terminal displays this message when building container. Not sure where the problem is.
(base) MacBook-Pro-de-Carlos-Arau:webscrap carlosarau$ docker-compose up
Building web
Step 1/5 : FROM python:2.7
---> 68e7be49c28c
Step 2/5 : WORKDIR /usr/src/app
---> Using cache
---> be06bd573b0f
Step 3/5 : ADD requirements.txt /usr/src/app
---> Using cache
---> eb33847b4acb
Step 4/5 : RUN pip install -r requirements.txt
---> Running in e16754e4db86
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting Flask==1.1.1
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)'),)': /packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)'),)': /packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)'),)': /packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)'),)': /packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)'),)': /packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)'),))
WARNING: You are using pip version 20.0.2; however, version 20.1.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Here you can find my Dockerfile and docker-compose yml
Dockerfile:
FROM python:2.7
WORKDIR /usr/src/app
ADD requirements.txt /usr/src/app
RUN pip install -r requirements.txt
ADD . /usr/src/app
docker-compose.yml:
version: '2'
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: 'xxx'
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/usr/src/app
depends_on:
- db
Running on Mac OS Yosemite with python 2.7 (unable to upgrade to 3.6)
Thanks for you help
I see that you use python2.7.
It is unsupported since january 2020. It is possible your problem comes from here.
Your build environment does not recognize the SSL certificate of https://files.pythonhosted.org as valid.
If the root certificate of files.pythonhosted.org was added in a more recent python version, that may explain it.
I strongly advise to find a way to update your python to python3 before anything else.

Pip Installation Problems EnvironmentError

I have no problems installing other dependencies but djangorestframework_simplejwt gives me the following error.
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))': /packages/3d/d7/92c717da4e3474fef8a5415391170eba60be16a4e531c9027c38b2c329c8/djangorestframework_simplejwt-3.2.3-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/3d/d7/92c717da4e3474fef8a5415391170eba60be16a4e531c9027c38b2c329c8/djangorestframework_simplejwt-3.2.3-py2.py3-none-any.whl (Caused by ProtocolError('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer')))
EDIT
It seems to be a problem with my virtualenv. When I deactivate it then pip works fine.
WORKAROUND
So I found a workaround for the time being. I deactivated my env, then did pip install djangorestframework-simplejwt, then source bin/activate to activate my env. Then I would run pip install djangorestframework-simplejwt, it would use the cached version.

ConnectTimeoutError installing Tensorflow on windows

I'm triying to install Tensorflow, and I get the following:
C:\>pip3 install --upgrade tensorflow
Collecting tensorflow
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by
ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x00000240DAD78BA8>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/tensorflow/
I've also tried to install it downloading the .whl on the GitHub repository, and I get the same kind of error:
C:\>pip3 install tensorflow-1.1.0-cp35-cp35m-win_amd64.whl
Processing c:\tensorflow-1.1.0-cp35-cp35m-win_amd64.whl
Collecting bleach==1.5.0 (from tensorflow==1.1.0)
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000001FEE571BCC0>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/bleach/
My PC is connected to my university's network which need a HTTP proxy configuration. Could it be the problem? How could I fix it?
So pip work abruptly behind proxy for that you can refer Using pip behind a proxy
But for your alternate you can download Tensorflow wheel from (Python 2 CPU)
For other Python Version or CPU/GPU
https://github.com/tensorflow/tensorflow#installation

Resources