pip install inside the conda environment - pip

I have the following setup inside the condarc file:
ssl_verify: true
use_pip: True
add_pip_as_python_dependency: True
channels:
- conda-forge
- defaults
proxy_servers:
http: proxyserver
https: proxyserver
I am using Anaconda behind the company proxy that those details about the proxy servers are mentioned under the http: and https: fields.
Once I activate the environment and issue the following command :
pip install -r requirements.txt
I am getting the following error:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after
connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at
0x000002A615C950D0>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/jinja2/

It seems to be an SSL error to me. I fixed it by bypassing as shown below:
pip install -r requirements.txt —trusted-host pypi.org —trusted-host files.pythonhosted.org
If you are in a corporate network it may occur due to firewall blockage. Try the above solution.

Related

How I can fix NewConnectionError in my pip installer?

I have a problem with my pip: any package I want to install returns an error message:
/usr/lib/python3/dist-packages/secretstorage/dhcrypto.py:15: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
/usr/lib/python3/dist-packages/secretstorage/util.py:19: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
from cryptography.utils import int_from_bytes
Defaulting to user installation because normal site-packages is not writeable
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fcfa2776760>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pip/
It isn't problem with my Internet or VPN or DNS, I have checked it.
Before a problem I have tried to install pgadmin and used those commands:
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo
apt-key add sudo sh -c 'echo "deb
https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs)
pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
sudo /usr/pgadmin4/bin/setup-web.sh sudo ufw allow 'Apache' sudo ufw
enable
And now I can't install anymore else :( Can somebody help me to fix it?

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

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.

PIP not working - 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

Resources