I tried the way as you mentioned above but still am getting different error.
Traceback (most recent call last):
File "D:/Python/25_10(2).py", line 3, in <module>
conn = cx_Oracle.connect('hr/hr@XE')
cx_Oracle.DatabaseError: ORA-12545: Connect failed because target host or object does not exist
1. Ensure your environment setup (TNS_ADMIN, ORACLE_SID etc) is proper by using sqlplus and connect it to your db.
2. Also you can refer https://github.com/oracle/python-cx_Oracle/blob/master/samples/tutorial/connect.py
Thanks for the guidance! As you suggested, the ORACLE_SID were wrong as I have used the wrong TNS.ora file. I changed and executed, it went fine.