microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.29k stars 1.17k forks source link

SSL error when 'run in terminal' but not when run via anaconda prompt #10015

Closed HughGrovesArup closed 4 years ago

HughGrovesArup commented 4 years ago

Environment data

Expected behaviour

Script should run with no errors. This is true for the same environment when run from anaconda prompt.

Actual behaviour

When run with 'run python file in terminal' I get an SSL exception (below).

Will this possibly be fixed with https://github.com/microsoft/vscode-python/issues/5559?

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Traceback (most recent call last):
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\urllib3\connectionpool.py", line 654, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\urllib3\connectionpool.py", line 274, in _get_conn
    return conn or self._new_conn()
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\urllib3\connectionpool.py", line 964, in _new_conn
    "Can't connect to HTTPS URL because the SSL module is not available."
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\urllib3\connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\urllib3\util\retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='compute.rhino3d.com', port=443): Max retries exceeded with url: /rhino/geometry/mesh/createfrombrep-brep (Caused by SSLError("Can't connect to HTTPS URL because the SSL module isan't connect to HTTPS URL because the SSL module is not available."))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Users/Hugh.Groves/Documents/VS_Code_Projects/RhinoComputePyTest/rcpyt.py", line 9, in <module>
    meshes = compute_rhino3d.Mesh.CreateFromBrep(brep)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\compute_rhino3d\Mesh.py", line 407, in CreateFromBrep
    response = Util.ComputeFetch(url, args)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\compute_rhino3d\Util.py", line 31, in ComputeFetch
    r = requests.post(posturl, data=postdata, headers=headers)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\requests\api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Hugh.Groves\AppData\Local\Continuum\Anaconda3\envs\rhinocompute\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='compute.rhino3d.com', port=443): Max retries exceeded with url: /rhino/geometry/mesh/createfrombrep-brep (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not connect to HTTPS URL because the SSL module is not available."))

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

[Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as undefined 
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path identified as shell 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path from user settings 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as powershell 
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell identified as 'powershell'
c:\Users\Hugh.Groves\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1 xterm.js: Terminal.open was called on an element that was not attached to the DOM
e._log @ c:\Users\Hugh.Groves\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
e.warn @ c:\Users\Hugh.Groves\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
t.open @ c:\Users\Hugh.Groves\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
e.open @ c:\Users\Hugh.Groves\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar\xterm\lib\xterm.js:1
(anonymous) @ terminalInstance.ts:573
processTicksAndRejections @ internal/process/task_queues.js:89
Promise.then (async)
_attachToElement @ terminalInstance.ts:558
attachToElement @ terminalInstance.ts:547
p @ terminalTab.ts:192
_addChild @ terminalTab.ts:105
split @ terminalTab.ts:47
(anonymous) @ terminalTab.ts:351
attachToElement @ terminalTab.ts:351
m @ terminalTab.ts:250
_createInstance @ instantiationService.ts:117
createInstance @ instantiationService.ts:82
createTerminal @ terminalService.ts:613
$createTerminal @ mainThreadTerminalService.ts:97
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
(anonymous) @ rpcProtocol.ts:101
fire @ event.ts:582
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:582
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path 'Python'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Terminal name 'Python' identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as other (Terminal name is Python)
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path identified as shell 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path from user settings 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as powershell (Terminal name is Python)
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell identified as 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Cached data exists getEnvironmentVariables, c:\Users\Hugh.Groves\Documents\VS_Code_Projects\RhinoComputePyTest\rcpyt.py
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path 'Python'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Terminal name 'Python' identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as other (Terminal name is Python)
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path identified as shell 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path from user settings 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as powershell (Terminal name is Python)
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell identified as 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Cached data exists getEnvironmentVariables, c:\Users\Hugh.Groves\Documents\VS_Code_Projects\RhinoComputePyTest\rcpyt.py
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path 'Python'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Terminal name 'Python' identified as shell 'other'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as other (Terminal name is Python)
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path identified as shell 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell path from user settings 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: [object Object]. Shell identified as powershell (Terminal name is Python)
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Shell identified as 'powershell'
console.ts:137 [Extension Host] Info Python Extension: 2020-02-10 11:45:31: Cached data exists getEnvironmentVariables, c:\Users\Hugh.Groves\Documents\VS_Code_Projects\RhinoComputePyTest\rcpyt.p
karthiknadig commented 4 years ago

@HughGrovesArup As you identified, this is a issue we see when the conda environment is not activated. This should be addressed when we fix #5559

DonJayamanne commented 4 years ago

@HughGrovesArup

Generally we activate the environment in the terminal. Looks like the activation is failing or the activation command hasn't even been sent to the terminal.

HughGrovesArup commented 4 years ago

@DonJayamanne the command that gets printed is:

& C:/Users/Hugh.Groves/AppData/Local/Continuum/Anaconda3/envs/rhinocompute/python.exe c:/Users/Hugh.Groves/Documents/VS_Code_Projects/RhinoComputePyTest/rcpyt.py

The screen looks like this:

image

karthiknadig commented 4 years ago

Using the new vsc API to activate terminal should help with this issue. Closing this in favor of #11039