“Can't connect to HTTPS URL because the SSL module is not available.”

独自空忆成欢 提交于 2020-04-16 04:46:31

问题


Hi guys I having trouble with SSL and python. I had a script that goes to f5 API with requests and it was worked fine. I did another API script. Tried it on another machine (some VPN system I can't provide the name) also with requests package since my python API script with requests package doesn't work. I know the problem started when I tried to approach the other machine's API because the problem I have is on 2 machines. On the other machine I did it on purpose to see if that was my problem (I was right sadly).

Example to script that worked:

def f5_ltm_01_active_status():

  response = requests.get("https://<ip-address>/mgmt/tm/cm/device/ver=12.1.3.4", auth=("user","password"),verify=False)

  try:
      json_response = response.json()
      if json_response["items"][0]['hostname']:
        return_str = "%s is %s" %(json_response["items"][0]['hostname'],json_response["items"][0]['failoverState'])
      else:
        return_str = "Wrong value in JSON"
  except:
    return_str = "Something went wrong ,  please check the code  "
  finally:
    return return_str

The error that the Python returned is:

raise SSLError(e, request=request) requests.exceptions.SSLError: 
HTTPSConnectionPool(host='ip-address-of-f5', port=443): Max retries 
exceeded 
with url: /mgmt/tm/cm/device?ver=12.1.3.4 (Caused by SSLError("Can't 
connect 
to HTTPS URL because the SSL module is not available."))

If I operate the script in debug mode it works.

I am using Windows 10

I am using Python v3.7.2

Another thing that I tried to do:

  1. looking in Stackoverflow for answers

  2. looking at Google to try to get answers

  3. erase Pycharm and reinstall

  4. erase python and reinstall

  5. erase requests pack and urllibs3 pack and reinstall

  6. install open-ssl - pyopenssl pack

I am really want to get an answer and idea of how and why did it happen but mainly how to fix it


回答1:


I was mistaken.

I made a Python file named ssl.py in the same project. Python must have been looking for ssl attributes at my ssl.py file.

When I erased that file it all worked out. I hope I was helping anyone with this post.



来源:https://stackoverflow.com/questions/54514668/cant-connect-to-https-url-because-the-ssl-module-is-not-available

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!