SSL Certificate/Module error - pip 19.2.3 - Anaconda Prompt - ssl

First off, let me say I'm a beginner programmer and so far I managed to 'get away' without understanding too much about virtual environments, command prompts, Python shells, so please apologise if I don't understand the terminology that well (yet, I am reading about it second day now).
I am using Windows 10 and Anaconda, Python 3.7.7, Spyder 4.2.1., iPython shell 7.13.
So far I installed packages using the console (iPython) and pip install, successfully, no problems there at all. However, now I have to create a virtual environment as part of a WebDevelopment course I am doing.
I managed to create a new environment (as part of an existing directory, the server) using the Anaconda prompt, and activate it. That seemed to work. Then I had to install Flask.
(Before, the unaware Me, installed it using pip in the console, and it worked, but obviously this is not in the environment I want for my project).
And just trying pip install flask (as well as pip3 install flask), from within the activated virtual environment (webServer), gave me the error:
(webServer) C:\Users\path\to\directory\Python\project>pip install
Flask WARNING: pip is configured with locations that require TLS/SSL,
however the ssl module in Python is not available. Collecting Flask
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/flask/ 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/flask/ 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/flask/ 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/flask/
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/flask/ Could not fetch URL
https://pypi.org/simple/flask/: There was a problem confirming the ssl
certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max
retries exceeded with url: /simple/flask/ (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 Flask (from versions: none) ERROR: No matching
distribution found for Flask 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
I have been reading about this error and I tried various things suggested, such as:
pip install --upgrade --user pip --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org
as well as
curl https://bootstrap.pypa.io/get-pip.py >> get-pip.py
python get-pip.py
Neither of these change anything. This is the first time I encounter this, because so far all my installations have been from the console, using the pip that is in the main Anaconda directory.
pip definitely exists in the site packages of the newly installed virtual environment though.
And here my basic knowledge is insufficient to get if it is something due to Anaconda, due to the new environment I set up, etc.
Any help will be appreciated.

PS For anyone who encounters this:
After a lot of digging and trial and error, I solved the problem by adding :
C:\Users\User\Anaconda3\Library\bin
to my PATH list of Environmental variables.

Related

In Sage: No module named 'Crypto' --> ssl errors with pip

I see from this answer that the solution is to run:
sage --pip install pycrypto
Yet, when I try this, I get the following error:
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/pycrypto/
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/pycrypto/
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/pycrypto/
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/pycrypto/
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/pycrypto/
Could not fetch URL https://pypi.org/simple/pycrypto/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pycrypto/ (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 pycrypto (from versions: none)
ERROR: No matching distribution found for pycrypto
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
Since you have Sage 9.2, I would suggest upgrading.
The best way to do so depends on
whether you intend to develop Sage or only use it
what extra packages you need to install with Sage
If you
only intend to use Sage
only need pip-installable packages
then consider installing the latest Sage-macOS from
https://github.com/3-manifolds/Sage_macOS/releases
Then launch Sage and, at the Sage prompt, run
%pip install pycrypto
and similarly for any pip-installable packages you need.
Then quit Sage and launch it again.

SSL Certificate error while installing Spacy

I am facing the below error while installing Spacy.
requests.exceptions.SSLError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /explosion/spacy-models/master/compatibility.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
Command i'm running : python -m spacy download en_core_web_md
I have fixed it by following the below steps.
Edited the .condarc file with ssl = false
while installing the anaconda, the default checkbox for PATH setup leave as it is.
Thanks

pip install failing with 407 Proxy Authentication Required

I am trying to use the below pip install command, but its failing with Proxy authentication required issue. I have already configured my proxies inside my RHEL7.x Server.
Command Used: `pip install --proxy https://'username:pwd'#proxy:host --upgrade pip`
Logs:
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/pip/
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/pip/
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/pip/
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/pip/
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/pip/
This is the first thing you should try:
Open the command prompt(CMD).
Export the proxy settings :
:\set http_proxy=http://username:password#proxyAddress:port
:\set https_proxy=https://username:password#proxyAddress:port
Install the package you want to install:
:\pip install PackageName
Error 407 means that the authentication for the proxy is missing / wrong. Remove the ' from the username:pwd part, i.e. use: pip install --proxy https://username:pwd#proxy:host.
Try opening an internet connection from that server just prior to installing the Python package, as another option.
If this is not helping, try the the options given in the answers to the questions here, here and here.
Open the terminal then execute:
export http_proxy=http://username:password#proxyAddress:port
export https_proxy=https://username:password#proxyAddress:port
I try this in git bash, in Windows.
I did not find a better answer with no password in a environment variable.
You could save this code, creating a ".bashrc" file in your home directory.
There's authentication problem while connecting to proxy which causes 407 proxy issue.
Execute following commands to set proxy for your system.
set HTTPS_PROXY=https://User_Name:Password#proxy_address:Port
set https_proxy=https://User_Name:Password#proxy_address:Port
set HTTP_PROXY=http://User_Name:Password#proxy_address:Port
set http_proxy=http://User_Name:Password#proxy_address:Port
Note: Check your environment environment variable has HTTP_PROXY/ HTTPS_PROXY variable set. If Yes, verify if those are set to correct values.
As these values overwrite your current values.

NewConnectionError when trying to install Tensorflow on Windows 10 with python 3.5

I am currently trying to install tensorflow with Python 3.5 and I am running into a new connection error. I am trying to follow the install guide from tensorflow. Has anyone seen this issue before and figured out a solution? Thanks.
c:\>pip3 install --upgrade tensorflow
Collecting tensorflow
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002245E6C30F0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',)': /simple/tensorflow/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002245E6D0470>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',)': /simple/tensorflow/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002245E6D05C0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',)': /simple/tensorflow/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002245E6D0710>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',)': /simple/tensorflow/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002245E6D0860>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',)': /simple/tensorflow/
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
This is not definitive, but I would suggest a few actions:
Consider testing from another machine on the same network, or even a different network, to test for actual network issues you might have.
This might be a temporary issue with the server, try again later.
Try to install some other package with pip, to rule out possible problems with your pip itself
Installing tensorflow doesn't have to be done with pip, you can either follow this link to install via anaconda, or this link to install tensorflow from source (however, source installations are not officially supported on windows)
In my case, the connection was blocked by Kaspersky. Temporary switching it off solved my issue.

Does buildout/easy_install/setup_tools verify SSL certificates?

I'm trying to diagnose this error:
Getting distribution for 'zc.buildout<2dev'.
Got zc.buildout 1.7.1.
Generated script '/opt/mytardis/releases/a549cd05272afe8f16c2fe5efe8158490acbde82/bin/buildout'.
Download error on http://pypi.python.org/simple/buildout-versions/: [Errno 104] Connection reset by peer -- Some packages may not be found!
Couldn't find index page for 'buildout-versions' (maybe misspelled?)
Download error on http://pypi.python.org/simple/: [Errno 104] Connection reset by peer -- Some packages may not be found!
Getting distribution for 'buildout-versions'.
STDERR: /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'src_root'
warnings.warn(msg)
While:
Installing.
Loading extensions.
Getting distribution for 'buildout-versions'.
Error: Couldn't find a distribution for 'buildout-versions'.
It happens deep inside a Chef + buildout installation stack. One thing I have discovered is that if I attempt to access the buildout-versions package directly:
$ wget https://pypi.python.org/packages/source/b/buildout-versions/buildout-versions-1.7.tar.gz#md5=731ecc0c9029f45826fa9f31d44e311d
--2013-07-09 12:50:18-- https://pypi.python.org/packages/source/b/buildout-versions/buildout-versions-1.7.tar.gz
Resolving proxy.redacted.com... 123.45.67.8
Connecting to proxy.redacted.com|123.45.67.8|:8080... connected.
ERROR: certificate common name “*.a.ssl.fastly.net” doesn’t match requested host name “pypi.python.org”.
To connect to pypi.python.org insecurely, use ‘--no-check-certificate’.
I can access the file fine from my desktop. So I suspect the proxy (provided by a university, and this server has to use it to reach the web). It's set with https_proxy=....
Is this the likely cause of buildout failing? Any way around it?
Your version of wget is too old.
wget started to support SNI (Server Name Indication) only since version 1.14 and that TLS extension is needed to be presented the correct certificate on pypi.python.org.
Yes, zc.buildout and easy_install both use urllib2 to retrieve HTTPS resources, which does not verify SSL certificates:
Warning: HTTPS requests do not do any verification of the server’s certificate.
Your wget tool does verify certificates, but your local certificate authorities certificates are incomplete, it seems; see SSL certificate rejected trying to access GitHub over HTTPS behind firewall for instructions on how to update those.
As for your original error, it appears your firewall proxy is doing the peer resets.
As per PEP 476, Python 2.7.9 remedies this situation. From that version onwards, urllib2 will verify SSL certificates by default.
Since Python 2.7.9 (released) / 3.4.3 (released soon), certificates are validated by default:
HTTPS certificate validation using the system's certificate store is
now enabled by default. See PEP 476 for details.
https://www.python.org/downloads/release/python-279/
you can try it:
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea --no-check-certificate