0

I am trying to set up VSCode to allow me to run Python programs.

I am on Windows 10.

Currently, it works fine if I create simple programs like:

# This all works fine
print("Hello World")
arr = [1,2,3]
print(arr)

However, when I go to use any external library, like numpy, I get the following error:

Traceback (most recent call last): File "c:/Users/jerry/Desktop/hello.py", line 3, in import numpy as np ImportError: No module named 'numpy'

So, I issue the following in my VSCode Terminal Window: pip install numpy

Which yields me the folowing:

PS C:\Users\jerry> pip install numpy
Collecting numpy
Exception:
Traceback (most recent call last):
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 539, in urlopen
    self._prepare_proxy(conn)
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 727, in _prepare_proxy
    conn.connect()
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 238, in connect
    ssl_version=resolved_ssl_version)
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "c:\python35-32\lib\ssl.py", line 376, in wrap_socket
    _context=self)
  File "c:\python35-32\lib\ssl.py", line 747, in __init__
    self.do_handshake()
  File "c:\python35-32\lib\ssl.py", line 983, in do_handshake
    self._sslobj.do_handshake()
  File "c:\python35-32\lib\ssl.py", line 628, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\adapters.py", line 370, in send
    timeout=timeout
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 574, in urlopen
    raise SSLError(e)
pip._vendor.requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python35-32\lib\site-packages\pip\basecommand.py", line 211, in main
    status = self.run(options, args)
  File "c:\python35-32\lib\site-packages\pip\commands\install.py", line 294, in run
    requirement_set.prepare_files(finder)
  File "c:\python35-32\lib\site-packages\pip\req\req_set.py", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "c:\python35-32\lib\site-packages\pip\req\req_set.py", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "c:\python35-32\lib\site-packages\pip\req\req_set.py", line 491, in _prepare_file
    session=self.session)
  File "c:\python35-32\lib\site-packages\pip\download.py", line 825, in unpack_url
    session,
  File "c:\python35-32\lib\site-packages\pip\download.py", line 673, in unpack_http_url
    from_path, content_type = _download_http_url(link, session, temp_dir)
  File "c:\python35-32\lib\site-packages\pip\download.py", line 857, in _download_http_url
    stream=True,
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\sessions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "c:\python35-32\lib\site-packages\pip\download.py", line 373, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "c:\python35-32\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 46, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "c:\python35-32\lib\site-packages\pip\_vendor\requests\adapters.py", line 431, in send
    raise SSLError(e, request=request)
pip._vendor.requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)
You are using pip version 7.1.2, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

I am unsure what to do, or how to fix this error. I have reviewed the following resources:

Neither had a workable solution. Any advice or assistance would be appreciated.

artemis
  • 6,857
  • 11
  • 46
  • 99
  • Two things. One, don't use `pip` as a command as you don't know what Python interpreter it is tied to; always use `-m pip` with the Python interpreter you want to install for. – Brett Cannon Mar 20 '19 at 18:58
  • Two, you can try upgrading pip as the message at the end suggests: `python -m pip install --upgrade pip` while substituting `python` with the appropriate Python interpreter. – Brett Cannon Mar 20 '19 at 18:59
  • Thanks for the suggestion @BrettCannon. Unfortunately, I try upgrading pip but get the exact same error message. – artemis Mar 20 '19 at 19:01

1 Answers1

0

This was due to an issue with a proxy server that was fixed with my firewall settings. The issue for me was the need to add a specific certificate authority that hosts an intranet-only collection of Python libraries.

That certificate authority and certificate are proprietary and cannot be posted.

artemis
  • 6,857
  • 11
  • 46
  • 99