Python 3.11 throws an error "raise RuntimeError("No SSL support included in this Python")" when running via Cron

I’m getting below error when trying to run the python scripts via crontab. It works when running it manually.

File python3.11/lib/python3.11/smtplib.py", line 776, in starttls
raise RuntimeError(“No SSL support included in this Python”)
RuntimeError: No SSL support included in this Python

The main difference in cron vs. the command line, is usually the environment.

Perhaps try:
https://stromberg.dnsalias.org/~strombrg/env-search.html

1 Like

Hi Daniel,

Link you’ve sent can’t be reach.

Weird thing is it works when i try to set the python path in crontab to /usr/bin/python3.6 instead of /opt/python3.11.1/python3.11/bin/python3.11. by the way script is for sending email report.

That’s odd. It’s working for me. Can anyone else reach it?

What do you get from /opt/python3.11.1/python3.11/bin/python3.11 -c 'import ssl;print(ssl)'?

From that path, it looks like you built your own Python. Note that as far as the build process is concerned, ssl is an optional module, and there’s just a note at the end of the build output to alert you to the fact that the _ssl extension module required by ssl didn’t build if ./configure couldn’t find usable OpenSSL headers and libraries.

Zachary thanks for the reply.

Here.

[root@azl-etlmut-p-01 ~]# /opt/mut/Python-3.11.1/python3.11/bin/python3.11 -c ‘import ssl;print(ssl)’

<module ‘ssl’ from ‘/opt/mu/Python-3.11.1/python3.11/lib/python3.11/ssl.py’>

I didn’t use SSL on the email script, port 25 was used and its perfectly fine when running from the shell but on crontab its throwing error.