Python3 ssl modue missing?

Good morning,

I’m not sure if I understand what is happening here, I’m getting this error out of the blue.
SSL should come with Python by default, is the error related to a missing path, or something happened with this module?

Can’t connect to HTTPS URL because the SSL module is not available.
ModuleNotFoundError: No module named ‘_ssl’

Where is this? Do you have a code example? Are you using python 3? in Rhino or Grasshopper? Which Rhino version?!

@eirannejad ! super thanks for your reply.

At some point Rhino crashed windows with blue screen. Since then I noticed that settings for keyboard shortcuts, aliases, display settings got lost. And I suspect that Python library might be corrupted.

I use python 3 and GHPython3 in Grasshopper.

numpy, for example, which I had installed now it’s not there anymore.
For example, import numpy in ScriptEditor will result in an error No module named ‘numpy’, and the following extended error in ScriptEditor Terminal:

Rhino.Runtime.Code.Execution.ExecuteException: Environment "default" is corrupted due to a possible package installation failure
 ---> Rhino.Runtime.Code.Environments.CorruptEnvironException: Environment "default" is corrupted due to a possible package installation failure
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonEnviron.ThrowIfCorrupt()
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.Run(RunContext context)
   --- End of inner exception stack trace ---
Rhino.Runtime.Code.Environments.CorruptEnvironException: Environment "default" is corrupted due to a possible package installation failure
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonEnviron.ThrowIfCorrupt()
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.Run(RunContext context)

In GHPython3, import requests will result in an error : Can’t connect to HTTPS URL because the SSL mo…

with the following error in the terminal:

Rhino.Runtime.Code.Execution.ExecuteException: Environment "default" is corrupted due to a possible package installation failure
 ---> Rhino.Runtime.Code.Environments.CorruptEnvironException: Environment "default" is corrupted due to a possible package installation failure
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonEnviron.ThrowIfCorrupt()
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.Run(RunContext context)
   --- End of inner exception stack trace ---
Rhino.Runtime.Code.Environments.CorruptEnvironException: Environment "default" is corrupted due to a possible package installation failure
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonEnviron.ThrowIfCorrupt()
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.Run(RunContext context)

and if I try to install a package i get this error:

So I really don’t know what to do here…

Reset your python 3 runtime and reopen Rhino. Let it initialize the runtime again. Then try installing numpy.

I restarted, now when I try to install i get this:

Hmm this is weird. Do you have these files?

%USERPROFILE%\.rhinocode\py39-rh8\Lib\ssl.py
%USERPROFILE%\.rhinocode\py39-rh8\DLLs\_ssl.pyd
%USERPROFILE%\.rhinocode\py39-rh8\DLLs\libssl-1_1.dll

%USERPROFILE%\.rhinocode\py39-rh8\Lib\ssl.py - yes
%USERPROFILE%\.rhinocode\py39-rh8\DLLs\_ssl.pyd - no
%USERPROFILE%\.rhinocode\py39-rh8\DLLs\libssl-1_1.dll -yes

Perhaps check your antivirus/security software to see if it is potentially quarantined? In case you have such software in use…

Okay that explains it. There is something e.g. Antivirus on your system that is deleting the _ssl.pyd file. That is the source for the ssl module

i haven’t installed any antivirus, everything was fine last week. Then blue screen… then this.

Not even Microsoft Defender, which is part of Windows…?

no Microsoft Defender. Only windows Virus & threat protection with no threats.

That is defender. You could try adding your %USERPROFILE%\.rhinocode to the exclusion list, reset the Python 3 runtime, and try again.

1 Like

I added to exclusions


then I get this

collecting

ok!

All good it seems!
Thank you very much gentlemen!

2 Likes