-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSL certificate error with pip 21.0.1 #9568
Comments
Do you have a internet proxy configured at the Config Panel -> Internet Options? If so disable it and try again. If it then times out, add the proxy on the command line using |
@bastiaan85 Not helping me. Similar output. I am able to install with previous versions. Once i upgrade pip to 21.0.1, packages stop installing. |
What does it print out when you launch a PowerShell and try the three commands mentioned in #9216 (comment) ? |
@bastiaan85 It prints out my proxy server and proxy port number. |
If it's printing it in the third command, then it means you didn't disable the proxy properly. If it prints it only in the first and/or second command, then verify that the url set there starts with 'http' and not 'https'. |
@bastiaan85 If I disable proxy, i wont be able to connect to internet. My PC is behind proxy and all other applications will stop working. |
I understand, but I don't know of a another way to be able to let pip download something via a http-only proxy. As the bug here is that urllib3 will assume the proxy it found in the system settings (third command) is a https-proxy and will not fall back to http when its request fails (that's why you see the SSL errors in pip). So until this is fixed in urllib3 the workaround is to disable the system proxy, set the proxy in the pip command line using |
I was fighting with my organization's networking team from last one month to remove this error and finally I got rid off it by using --proxy http://address:port |
I downgrade pip to 20.2.3 and it works fine. |
I have the same problem on Linux with Python 3.9.1, and running pip install (20.2.3) does not fix it. I am behind an SSL proxy which I can't circumvent, so I can only re-install Python and then everything I installed since (except for a newer pip). |
That can't be the same issue. The mentioned issue is Windows users behind a HTTP proxy, as there the 'system proxy' is set using the Internet Options panel, which then gets picked up by urllib3, assumed to be a HTTPS proxy, so it uses a SSL client, which then fails on the proxy (being a dumb HTTP endpoint) not responding with a proper SSL handshake. This is represented by the This could be related to either a schema mismatch ( |
My proxy setup is correct, and furtnermore, out of my control (corporate networking here). I've successfully installed a number of packages with the original version of pip. But after upgrading, I got the SSL protocol mismatch problem, and after downgrading, my connections just time out. I would like to debug further, but don't know how. |
I understand, but the point I'm trying to make is that you are replying to a thread that discusses an opposite issue. Protocol mismatch usually means you are using a HTTP client on a HTTPS endpoint, while the thread is about urrllib3 erroneously using HTTPS for a HTTP system proxy. However the 'protocol mismatch' does confirm that you are using an SSL proxy, so that points toward my first suggestion above.
Use |
Thanks, problem solved. My bad... |
I have found the root cause of the problem and pip can fix its end. I understand that urllib is getting the wrong scheme for https. A workaround would be to Saying that pip has a way to pass proxy running: I'm using pip 21.0.1 to debug and a venv. To reproduce:
I would expect pip to use the proxy I'm passing to it and override any system proxy, but that is not the case. To see that add a breakpoint at the request method from PipSession class in So basically pip is not passing through the proxies set by the user when invoking pip, and that is the root cause of all the following errors with SSL. This is the original request method of PipSession: def request(self, method, url, *args, **kwargs):
# Allow setting a default timeout on a session
kwargs.setdefault("timeout", self.timeout)
# Dispatch the actual request
return super().request(method, url, *args, **kwargs) An easy fix I suggest is to add the following line at the request method in the file pi_internal\network\session.py: def request(self, method, url, *args, **kwargs):
# Allow setting a default timeout on a session
kwargs.setdefault("timeout", self.timeout)
kwargs.setdefault("proxies", self.proxies) # fix problem with proxies.
# Dispatch the actual request
return super().request(method, url, *args, **kwargs) This way the proxies are carried out correctly to the request, if no proxy is set an empty dict is passed. So now if you run I hope this will help to remove this bug in the next version of pip asap. |
Thank you, that sounds like a good analysis. If someone is interested in raising a PR for this (preferably including a test that fails with current pip, so that we can avoid any regressions in future), we can look at getting this fix applied. |
So there are two reasons for this error:
|
@CrazyBoyFeng First, thank you to take this problem into consideration. I don't think the problem with However, it is pip's child class ( this is a pice of code inside requests.Session.request(): def request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None):
proxies = proxies or {}
settings = self.merge_environment_settings(
prep.url, proxies, stream, verify, cert
) You can see that proxies will be an empty dict if nothing is passed to it. Then However, if pip calls his method passing the proxy, everything works fine. As I have mentioned in the post above. The method This is a tricky situation because usually there is no reason for the It's also worth mentioning that this problem is not only related to Windows, I also have a problem using pip >= 20.3 in a Linux server via Ansible. If you fix the problem with |
Yes, you are right. I have found I waste hours on Do you plan to make a PR patch? |
Would be nice if you could do the PR patch or someone else. Currently, I'm using working hours for that...so :) |
Ubuntu1604, same issue |
This issue also happens even when you have configured the proxy through I have configured the proxy through Downgrading to pip 20.2.3 fixes the issue though : the http proxy is used, and the installation is successfull. |
Thank you everyone for digging into this and actually finding a solution, but just for the record, I would like to note that my problem is completely unrelated to Windows, as I have been working on Linux only. |
That's why there were two reasons mentioned, not just one. |
On Windows 10, the following two steps allowed me to install pip packages in a conda environment.
|
Thank you for this workaround! |
|
Further debugging shows that, for some very strange reason, I can't load the SSL module in Python 3.9.5, but can load it in Python versions 3.6, 3.7 and 3.8, compiled with the same settings on the same machine, and in the same shell. I'm not sure whether this is the same bug as before, or a different bug? I am hesitant to "test", since I don't know how to revert to an older version of pip - it seems to only support going forward, not backward. |
The ssl module is built in, so if it changes in 3.9, you should report this to CPython, pip maintainers can't do anything for you. |
I had this error message as well, with python-3.9.6-amd64 on Win10. I downgraded to python-3.8.3-amd64, rebooted, and this SSL error disappeared. I can now use pip again. |
After waiting a long time for a fix on the side of the request that could fix pip install issues with proxy as already discussed in pypa#9691. It seems that such changes as mentioned in psf/requests#5735 will take a while to happen, probably only on version 3 of the request. Therefore, I'm suggesting a change on the pip side as already proposed in [issuecomment-79051687]pypa#9568 (comment) and [issuecomment-939373868]psf/requests#5735 (comment) I think it's important that pip address this issue asap since the newer versions of pip are not working properly behind a proxy.
Some news from psf/requests#5735: |
@CrazyBoyFeng That's correct. |
@junqfisica |
In my case (Windows 10, corporate proxy, pip 21.2.3, python 3.10.0) I solved the issue after reading, attempting and mixing a lot things.
You need to set the 2 variables with appropriate values. NB https_proxy var doesn't contain "https://" but "http://"
If you stop at this point, and try for example :
After having launched I pasted the temporary file content into Then, I successfully could install modules with Et voilà, c'est tout simple ! Nicolas. |
I imagine this issue has users who are trying to use pip within an organisation, behind a proxy or something else. Please see #8200 (comment) if that's your situation. Some of the cases affected by proxy issue should also have been fixed by #10680 (which will the next pip release). There's a Windows-specific Python standard library bug (https://bugs.python.org/issue42627) that doesn't really need to be tracked on our end. Closing this, since I don't think there isn't really anything actionable left here, that would involve making a dedicated code change in this project. |
pip version
21.0.1
Python version
3.7
OS
Windows 10
Additional information
After upgrading pip to latest version i.e. 21.0.1, I am unable to install any other packages.
Description
I am able to install packages with previous versions (19.0.3) of pip. Problem is with only 21.0.1.
Expected behavior
No response
How to Reproduce
Step 1 :
python -m pip install --upgrade pip
Step 2:
pip install matplotlib
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: