I was setting up a proxy yesterday on Ubuntu for a test as well as installed some mono libs including new certs for the Linux build of fiddler. After turning off all my proxy settings (such as going to the network settings and turning off the proxy "System wide") I can hit the network normally through all the tools except python. The browsers works fine, I can ping endpoints, I can use wget and curl without any issue, but python's network settings seem screwed up.
Here's the output when I run pip install -U pyopenssl:
$ pip install -U pyopenssl
Collecting pyopenssl
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f89bd58dfd0>: Failed to establish a new connection: [Errno 111] Connection refused',))': /simple/pyopenssl/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f89bd58db10>: Failed to establish a new connection: [Errno 111] Connection refused',))': /simple/pyopenssl/
...
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f89bd595f90>: Failed to establish a new connection: [Errno 111] Connection refused',))': /simple/pyopenssl/
Could not find a version that satisfies the requirement pyopenssl (from versions: )
No matching distribution found for pyopenssl
Running a simple test urllib2 also fails (urllib2.URLError: ):
import urllib2
def internet_on():
try:
urllib2.urlopen('http://216.58.192.142', timeout=1)
print "it worked!"
return True
except urllib2.URLError as err:
print "it did not work"
return False
internet_on()
The requests library also instantly fails in some tools I use:
requests.exceptions.ProxyError: HTTPConnectionPool(host='127.0.0.1', port=8888): Max retries exceeded with url: http://10.30.0.63/ (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4c9c327f90>: Failed to establish a new connection: [Errno 111] Connection refused',)))
I'm guessing python thinks I'm behind a proxy when I'm not anymore. Is there a way to debug or reset python's network configuration?
Fixed the issue. Based on heemayl's comment about an http_proxy variable I checked the environment variables in my bashrc and saw a script had probably added http_proxy and https_proxy, which urllib.getproxies() uses.
Removing those lines fixed the issue. Thanks, heemayl.
Have you tried using the pip --trusted-host pypi.python.org and/or --proxy http://PROXYNAME.com?
I've had similar experiences with pip interacting with system proxies. I imagine pip looks to pypi, hits the proxy, and doesn't find a distribution matching (logically).
The full command would look something like:
pip install -U --trusted-host pypi.python.org --proxy http://PROXYNAME.com pyopenssl
Trusted host helps if your proxy interferes with the certificates.
Let me know if that helps! Also, check env | grep proxy just in case something is wonky with the way you are setting the proxy in the environment.
More generally, check out this question about handling proxies with urllib.
Related
I have tried installing or updating new packages in my windows 10 system wherein I have installed Anaconda3 (2019 version).But everytime I get the same SSL error. I would have suspect it could be company firewall issue , if the I could have accessed that in Home wifi network. But everywhere I get the same error .
While running COnda Search, I get this error :
conda search
Loading channels: failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/win-64/repodata.json.bz2>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))
And with Pip install I get this error :
pip install keras
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting keras
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/keras/
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/keras/
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/keras/
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/keras/
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/keras/
Could not fetch URL https://pypi.org/simple/keras/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/keras/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not find a version that satisfies the requirement keras (from versions: )
No matching distribution found for keras
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 OpenSSL installed from this location "https://slproweb.com/products/Win32OpenSSL.html" and have the lib folder set in the PATH variable. But nothing it working . Please suggest .
I was able to solve the issue following THIS instructions.
Basically:
* copy the following files from CONDA_PATH\Library\bin to CONDA_PATH\DLLs
libcrypto-1_1-x64.*
libssl-1_1-x64.*
On Miniconda, Win11 Pro x64. Wanted to create a new env and conda install pip and got the same issue suddenly.
Update base
conda update --all in (base) first and then trying conda install pip or whatever you tried again.
Didn't work
Install latest OpenSSL
Didn't work
Copy latest OpenSSL DLLs to \bin and \DLLs directory
Copy libcrypto-3-x64.dll + libssl-3-x64.dll
from C:\Program Files\OpenSSL-Win64\bin
to C:\Users\username\anaconda3\Library\bin
and to C:\Users\username\anaconda3\Library\DLLs
Didn't work
Copy existing dlls from \bin to \DLLs
Copy libcrypto-1_1-x64.dll and libssl-1_1-x64.dll
from C:\Users\username\miniconda3\Library\bin
to C:\Users\username\miniconda3\DLLs
Worked
conda update conda
Collecting package metadata (current_repodata.json): failed
CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to
download and install packages.
Exception: HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
Solutions to above issues:
1. Try using Anaconda powershell prompt as shown in below image:
2. via base environement
a. conda activate base
b. conda update --all
Note:
a. Conda always create default environment as base. we can activate the base environment to upgrade the conda.
This worked for me:
conda install openssl
Download openssl here https://sourceforge.net/projects/openssl/ and insta;; in the main folder
Try to execute the conda commands with the Anaconda Prompt
This worked for me. Such a simple fix.
Taken from: https://github.com/conda/conda/issues/8273
Current Behavior Environment: Windows 2016 Server Installer:
https://repo.anaconda.com/archive/Anaconda3-2018.12-Windows-x86_64.exe
with the fresh installation neither conda nor pip are able to work
Steps to Reproduce Start Anaconda Prompt conda search conda gives an error message: Can't connect to HTTPS URL because the SSL module is
not available
Environment Information conda version : 4.5.12
Resolution I did a trace with Process Monitor.
D:\Anaconda3\DLLs_ssl.pyd search for the OpenSSL DLLs but in the
wrong/current location! As they are not found the search goes to
C:\Windows\System32 where we have the same DLLs, installed by an other
application, but with a different version. :-(
The DLLs delivered by Anaconda3 are located here:
D:\Anaconda3\Library\bin
My workaround: I have copied the following files libcrypto-1_1-x64. libssl-1_1-x64. from D:\Anaconda3\Library\bin to D:\Anaconda3\DLLs.**
And it works as a charm!
I need to download a package using pip. I ran pip install <package> but got the following error:
[user#server ~]$ pip install sistr_cmd
Collecting sistr_cmd
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.
VerifiedHTTPSConnection object at 0x7f518ee0cd90>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/sistr-cmd/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.
VerifiedHTTPSConnection object at 0x7f518ee0c290>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/sistr-cmd/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.
VerifiedHTTPSConnection object at 0x7f518ee0c510>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/sistr-cmd/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.
VerifiedHTTPSConnection object at 0x7f518ee0cf10>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/sistr-cmd/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.
VerifiedHTTPSConnection object at 0x7f518ee0c190>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/sistr-cmd/
Could not find a version that satisfies the requirement sistr_cmd (from versions: )
No matching distribution found for sistr_cmd
I verified that the source of the problem is the network blocking most sites because I am working behind a proxy (required by the organization). To allow these downloads, I need to compile the list of urls of the source of the downloads and send it to the network admins to unblock.
According to pip documentation (cited and explained in brief in the pip Wikipedia article), “Many packages can be found in the default source for packages and their dependencies — Python Package Index (PyPI)," so I went to the PyPI page for Biopython and found the github repository and the required dependencies for the package. There are also download links on the PyPI page and I want to be sure that all sources for the download are allowed. So does pip install from the original source of a package (the github repository or wherever the original package is hosted), the packages listed in the PyPI page under downloads, or does it search through both?
Thank you in advance for the help.
It appears a network connection, later you may try below:
pip install sistr-cmd
See the difference between - and _ for more info check here
According to user abarnert:
"If you run pip with the --verbose flag, it will show you all the links it considers. Generally speaking, it goes to https://pypi.org/simple/{PACKAGE} first. That page will have links to downloads for wheels and source for all versions that the maintainer has uploaded, and it will look for the appropriate version's wheel by trying its links in order. Usually there is no github repo listed as a source.
If you want to install everything from github (or any other location) that you know, the simplest thing to do is to manually give the repo to pip instead of just the package names. Ideally, install everything you care about that way on a machine that isn't firewalled from most of the internet, build a requirements.txt file (as explained here), then copy that requirements file to your firewalled machine and try to install it."
Running pip install with the --verbose flag shows extensive detail about where the package is being pulled from and about the network connection and traceback.
I keep getting the following error when I try to install or update modules with Conda. Any help?
I install using the following commands (basically any installation or upgrade command):
conda install tensorflow
conda install numpy
And this is the error message:
Fetching package metadata ... CondaHTTPError: HTTP 000 CONNECTION
FAILED for url
Elapsed: -
An HTTP error occurred when trying to retrieve this URL. HTTP errors
are often intermittent, and a simple retry will get you on your way.
ConnectionError(MaxRetryError("HTTPSConnectionPool(host='pypi.python.org',
port= 443): Max retries exceeded with url:
/simple/win-64/repodata.json (Caused by New
ConnectionError(': Failed to establish a new connection: [Errno
11004] getaddrinfo fail ed',))",),)
Also pip is not able to install any modules either. It keeps saying:
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection : [Errno 11004] getaddrinfo failed',)': /simple/tensorflow/
My guess is you installed Anaconda on a work computer behind a firewall. I had the same issues after installing it on my work laptop too, but no problems at all with the installation on my personal laptop at home. Please see this answer for setting up a .condarc config file in your home directory which is typically c:\users[your user id].
The answer addresses both config entries for proxy servers and ssl verification.
https://stackoverflow.com/a/54621792/5745815
I'm trying to install a Python pip package on Windows 10. Unfortunately, the proxy at my work is giving me trouble.
Things I've tried:
python -m pip install --proxy "http://sam.s1:1234#proxy.det.nsw.edu.au:8080"
python -m pip install --proxy http://sam.s1:1234#proxy.det.nsw.edu.au:8080
& 2. with the protocol changed to https
& 2. omitting the protocol, eg: python -m pip install --proxy sam.s1:1234#proxy.det.nsw.edu.au:8080
set HTTP_PROXY=sam.s1:1234#proxy.det.nsw.edu.au:8080 set HTTPS_PROXY=%HTTP_PROXY% set FTP_PROXY=%HTTP_PROXY%
Editing the proxy address for the HTTP_PROXY env variable in the same way described in steps 1 to 4.
Creating a pip.ini file at %APP_DATA%/pip/ with the following contents:
[global]
proxy = "http://sam.s1:1234#proxy.det.nsw.edu.au:8080"
trusted-host = pypi.python.org
Editing the proxy address in the pip.ini file in the same way described in steps 1 to 4.
They all give me similar errors such as:
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002A6F091B080>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))': /simple/django/
and
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002142813B128>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/
and
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/django/
Although sorting out once and for all how to download packages though the proxy would be nice, I'll settle for instructions on any methods that circumvent the proxy entirely, like downloading the package and compiling from source (I usually use Ubuntu, so I have no idea how to do this type of thing on Windows).
Other information:
The proxy is configured via a pac script
The package I'm currently trying to install is Django, but there will probably be others in the future.
I installed pip when I installed Python 3.6.3 (via the checkbox that says something like, do you also want to install pip as well as Python).
I know that pip is grabbing the settings from the .ini file, since I can change the output of $ pip list by setting a value for [list].
I have no idea about the proxy thing, but you can download Python packages from the Python Package Index (PyPI) and install them with pip. There's no need to compile from source in most cases, and definitely not with Django.
You can download Django here and then install it with pip install <path to downloaded package>.
I need to upgrade pip, and I'm using:
# python get-pip.py --proxy=[user:Password#]10.20.30.1:8082
but I get:
etrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fa5a1e84550>: Failed to establish a new connection: [Errno -2] Name or service not known',))': /simple/pip/
The proxy is working fine.
What type of proxy is it? If it is an NTLM proxy you need to use CNTLM
and then configure it with your proxy details.
Then set your --proxy for PIP to 127.0.0.1:3128