pythonpipssl-certificatevalueerror

Pip install returning a ValueError


I recently tried to install a library using Pip, and I received this error message. I am unable to install any packages, as the same error message keeps popping up.

I notice this problem in both my main enviroment, and my venv Virtual Environment.

Any help will be much appreciated.

WARNING: Ignoring invalid distribution -illow (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -aleido (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -aleido (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
ERROR: Exception:
Traceback (most recent call last):
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
    return func(self, options, args)

  ...

    resp = self.send(prep, **send_kwargs)
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\requests\sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 57, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\requests\adapters.py", line 440, in send
    resp = conn.urlopen(
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 1040, in _validate_conn
    conn.connect()
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\urllib3\connection.py", line 401, in connect
    context.verify_mode = resolve_cert_reqs(self.cert_reqs)
  File "c:\users\brdwoo\appdata\local\programs\python\python39\lib\ssl.py", line 720, in verify_mode
    super(SSLContext, SSLContext).verify_mode.__set__(self, value)
ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled.
WARNING: Ignoring invalid distribution -illow (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -aleido (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -aleido (c:\users\brdwoo\appdata\local\programs\python\python39\lib\site-packages)
WARNING: There was an error checking the latest version of pip.

Solution

  • I was able to fix the problem by hard-coding in a 1, instead of having CERT_NONE being passed to verify_mode.

    The error message gave me the location of the code:

     File "C:\Users\name\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 738, in verify_mode
        super(SSLContext, SSLContext).verify_mode.__set__(self, 0)
    ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled.
    

    I swapped the variable value -> 1

    @verify_mode.setter
    def verify_mode(self, value):
        super(SSLContext, SSLContext).verify_mode.__set__(self, 1)