how to install networkx package on CPython - installation

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

Related

Issues in installation of rasa-x to office laptop

I tried below command to install rasa-x on my office laptop:
python -m pip install rasa-x --extra-index-url https://pypi.rasa.com/simple
but it gave me below error:
Looking in indexes: https://pypi.org/simple, https://pypi.rasa.com/simple
Collecting rasa-x
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /rasa-packages/8789/rasa-x/rasa_x-0.31.0-py3-none-any.whl?Signature=hPxskutJmwG%2BUsEc8KuXK5JZ1%2B8P2FGKtUzD8dQGgTlKilNJyNJJO5WrCb1ON2E50k8qjLDHGkjx1XWLjxMfsJUD5wrekFPyeSPSadIgk21lNHzi7NgPi0r9NAl4t6pNln%2FPTtabxzY358ZYiov4wXAEAGyi8BxkAQZ73mnSSK4NE%2FlNnq1%2FVuZknUI3c3NBIbHZBgFExsx33kVpXfD4uGH%2FSdKWV0b9UJBnAPG3UM9OQ8EdJSB7ZYNPup1KEJuYvtrWWh7VrtvzhrmRy48RylbJZN9MlPcb02uoxDQ8uCOLGxyPUuk9sn0C8IYH6mdnUK5ODjQmA3DVxKz5l%2BuN6w%3D%3D&GoogleAccessId=pypi-storage%40pypi-190908.iam.gserviceaccount.com&Expires=1595317457
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /rasa-packages/8789/rasa-x/rasa_x-0.31.0-py3-none-any.whl?Signature=hPxskutJmwG%2BUsEc8KuXK5JZ1%2B8P2FGKtUzD8dQGgTlKilNJyNJJO5WrCb1ON2E50k8qjLDHGkjx1XWLjxMfsJUD5wrekFPyeSPSadIgk21lNHzi7NgPi0r9NAl4t6pNln%2FPTtabxzY358ZYiov4wXAEAGyi8BxkAQZ73mnSSK4NE%2FlNnq1%2FVuZknUI3c3NBIbHZBgFExsx33kVpXfD4uGH%2FSdKWV0b9UJBnAPG3UM9OQ8EdJSB7ZYNPup1KEJuYvtrWWh7VrtvzhrmRy48RylbJZN9MlPcb02uoxDQ8uCOLGxyPUuk9sn0C8IYH6mdnUK5ODjQmA3DVxKz5l%2BuN6w%3D%3D&GoogleAccessId=pypi-storage%40pypi-190908.iam.gserviceaccount.com&Expires=1595317457
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /rasa-packages/8789/rasa-x/rasa_x-0.31.0-py3-none-any.whl?Signature=hPxskutJmwG%2BUsEc8KuXK5JZ1%2B8P2FGKtUzD8dQGgTlKilNJyNJJO5WrCb1ON2E50k8qjLDHGkjx1XWLjxMfsJUD5wrekFPyeSPSadIgk21lNHzi7NgPi0r9NAl4t6pNln%2FPTtabxzY358ZYiov4wXAEAGyi8BxkAQZ73mnSSK4NE%2FlNnq1%2FVuZknUI3c3NBIbHZBgFExsx33kVpXfD4uGH%2FSdKWV0b9UJBnAPG3UM9OQ8EdJSB7ZYNPup1KEJuYvtrWWh7VrtvzhrmRy48RylbJZN9MlPcb02uoxDQ8uCOLGxyPUuk9sn0C8IYH6mdnUK5ODjQmA3DVxKz5l%2BuN6w%3D%3D&GoogleAccessId=pypi-storage%40pypi-190908.iam.gserviceaccount.com&Expires=1595317457
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /rasa-packages/8789/rasa-x/rasa_x-0.31.0-py3-none-any.whl?Signature=hPxskutJmwG%2BUsEc8KuXK5JZ1%2B8P2FGKtUzD8dQGgTlKilNJyNJJO5WrCb1ON2E50k8qjLDHGkjx1XWLjxMfsJUD5wrekFPyeSPSadIgk21lNHzi7NgPi0r9NAl4t6pNln%2FPTtabxzY358ZYiov4wXAEAGyi8BxkAQZ73mnSSK4NE%2FlNnq1%2FVuZknUI3c3NBIbHZBgFExsx33kVpXfD4uGH%2FSdKWV0b9UJBnAPG3UM9OQ8EdJSB7ZYNPup1KEJuYvtrWWh7VrtvzhrmRy48RylbJZN9MlPcb02uoxDQ8uCOLGxyPUuk9sn0C8IYH6mdnUK5ODjQmA3DVxKz5l%2BuN6w%3D%3D&GoogleAccessId=pypi-storage%40pypi-190908.iam.gserviceaccount.com&Expires=1595317457
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)'))': /rasa-packages/8789/rasa-x/rasa_x-0.31.0-py3-none-any.whl?Signature=hPxskutJmwG%2BUsEc8KuXK5JZ1%2B8P2FGKtUzD8dQGgTlKilNJyNJJO5WrCb1ON2E50k8qjLDHGkjx1XWLjxMfsJUD5wrekFPyeSPSadIgk21lNHzi7NgPi0r9NAl4t6pNln%2FPTtabxzY358ZYiov4wXAEAGyi8BxkAQZ73mnSSK4NE%2FlNnq1%2FVuZknUI3c3NBIbHZBgFExsx33kVpXfD4uGH%2FSdKWV0b9UJBnAPG3UM9OQ8EdJSB7ZYNPup1KEJuYvtrWWh7VrtvzhrmRy48RylbJZN9MlPcb02uoxDQ8uCOLGxyPUuk9sn0C8IYH6mdnUK5ODjQmA3DVxKz5l%2BuN6w%3D%3D&GoogleAccessId=pypi-storage%40pypi-190908.iam.gserviceaccount.com&Expires=1595317457
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='storage.googleapis.com', port=443): Max retries exceeded with url: /rasa-packages/8789/rasa-x/rasa_x-0.31.0-py3-none-any.whl?Signature=hPxskutJmwG%2BUsEc8KuXK5JZ1%2B8P2FGKtUzD8dQGgTlKilNJyNJJO5WrCb1ON2E50k8qjLDHGkjx1XWLjxMfsJUD5wrekFPyeSPSadIgk21lNHzi7NgPi0r9NAl4t6pNln%2FPTtabxzY358ZYiov4wXAEAGyi8BxkAQZ73mnSSK4NE%2FlNnq1%2FVuZknUI3c3NBIbHZBgFExsx33kVpXfD4uGH%2FSdKWV0b9UJBnAPG3UM9OQ8EdJSB7ZYNPup1KEJuYvtrWWh7VrtvzhrmRy48RylbJZN9MlPcb02uoxDQ8uCOLGxyPUuk9sn0C8IYH6mdnUK5ODjQmA3DVxKz5l%2BuN6w%3D%3D&GoogleAccessId=pypi-storage%40pypi-190908.iam.gserviceaccount.com&Expires=1595317457 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
But I thought This can happen if a corporate proxy is not allowing access to pypi.org.” I further tried to install rasa-x with below command:
python -m pip install --trusted-host=pypi.python.org rasa-x
But still I am getting below error:
Collecting rasa-x
Using cached rasa-x-0.0.2.tar.gz (1.4 kB)
ERROR: Command errored out with exit status 1:
command: 'C:\ProgramData\Anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\agupt80\\AppData\\Local\\Temp\\pip-install-wnjmorry\\rasa-x\\setup.py'"'"'; __file__='"'"'C:\\Users\\agupt80\\AppData\\Local\\Temp\\pip-install-wnjmorry\\rasa-x\\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 'C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2'
cwd: C:\Users\agupt80\AppData\Local\Temp\pip-install-wnjmorry\rasa-x\
Complete output (13 lines):
running egg_info
creating C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2\rasa_x.egg-info
writing C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2\rasa_x.egg-info\PKG-INFO
writing dependency_links to C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2\rasa_x.egg-info\dependency_links.txt
writing top-level names to C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2\rasa_x.egg-info\top_level.txt
writing manifest file 'C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2\rasa_x.egg-info\SOURCES.txt'
reading manifest file 'C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2\rasa_x.egg-info\SOURCES.txt'
writing manifest file 'C:\Users\agupt80\AppData\Local\Temp\pip-pip-egg-info-ghomfeg2\rasa_x.egg-info\SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\agupt80\AppData\Local\Temp\pip-install-wnjmorry\rasa-x\setup.py", line 39, in <module>
raise RuntimeError('Please use `pip install rasa-x -i https://pypi.rasa.com/simple` instead to install the rasa-x package')
RuntimeError: Please use `pip install rasa-x -i https://pypi.rasa.com/simple` instead to install the rasa-x package
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Can someone please help me on this.
Thanks & Regards
Amit Gupta
This should work. give a shot.
“pip install rasa-x -i https://pypi.rasa.com/simple --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.rasa.com --trusted-host storage.googleapis.com --proxy=proxy.example.com”

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

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