7

I am trying to access a pypi url like this:

PYPI_URL = https://pypi.org/pypi/Django/json

try:
    response = requests.get(PYPI_URL)

except requests.exceptions.RequestException as err:
    print("Unable to access Pypi. ", err)

But when I am trying to generate vcr cassettes for a pytest, I get this error.

E       AssertionError: assert 'Unable to access Pypi' not in "Unable to acce...l.c:1108)')))\n"
E         'Unable to access Pypi' is contained here:
E           Unable to access Pypi. Error Connecting:  HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi/Django/json (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))
E         ? +++++++++++++++++++++

What am I doing wrong? Why does it complain only when I try to generate cassette? The test passes if I just run pytest without generating VCR cassette.

urawesome
  • 198
  • 1
  • 10
  • I found this bit on a problem similar to this, it appears to be that the problem is SSL doesn't return a very informative error when the wrong port is used. If you can find out what port you should access, and compare that to what you *are* accessing, that may be a step in the right direction. https://bugs.python.org/issue35422 – OakenDuck Jul 27 '20 at 20:23
  • I am using port 80. How to find which port I should be using? – urawesome Jul 27 '20 at 20:39
  • Looks like your Python installation is compiled against an old version of OpenSSL. What are: 1. your Python version (`python -V`), 2. your OpenSSL version (`openssl version`) and 3. the version of OpenSSL Python was linked against (`python -c "import ssl; print(ssl.OPENSSL_VERSION)"`)? – hoefling Jul 28 '20 at 13:49

0 Answers0