0

i'm trying to run python scripts from .net using pythonnet in ubuntu (wsl). but when import ssl, I got the following error

Python.Runtime.PythonException: ModuleNotFoundError : No module named '_ssl'
  File "/usr/local/lib/python3.8/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate

but I have openssl installed. running the following from python

import ssl
ssl.OPENSSL_VERSION

correctly returned 'OpenSSL 1.1.1f 31 Mar 2020'

i've tried adding "/lib:/usr/lib" to both PYTHONPATH env and PythonEngine.PythonPath but it still cannot locate _ssl.so from within pythonnet

dna01
  • 33
  • 3

1 Answers1

1

found the issue. I need to add /usr/local/lib/python3.8/lib-dynload to PythonEngine.PythonPath. somehow adding only /usr/local/lib/python3.8 is not enough.

so I ended up having to list all of these /usr/local/lib/python3.8:/usr/local/lib/python3.8/lib-dynload:/usr/local/lib/python3.8/site-packages to make it work

not sure what the traversing logic to resolve python module used by python.net is. if anyone have explanation for this please post an answer

dna01
  • 33
  • 3