easy_install cx_Oracle (python package) on Windows

后端 未结 4 1388
天命终不由人
天命终不由人 2020-12-06 05:54

So I found Help installing cx_Oracle but am still stuck. I downloaded the latest instantclient from oracle, and set ORACLE_HOME to the location of the extracted files (both

4条回答
  •  既然无缘
    2020-12-06 06:15

    After struggling I found below method. I am using Windows and have separate environment for django.

    1. Follow this link and go to Windows section. Now under Oracle "Instant Client Zip" you will see first step to download zip file depending on which version and bit you need. Download zip file.Remember django 2 dont support Oracle 11.
    2. On Windows create below folder structure c:\oracle\instantclient_12_2
    3. unzip your files under this folder.
    4. Set the PATH in Control Panel -> System -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> PATH. The Instant Client directory must come in PATH before any other Oracle directories.
    5. Open other command prompt or restart current one.
    6. conda activate
    7. type python
    8. run all below command one by one to test connection, mind the indentation at the last for loop.

      import cx_Oracle
      
      connection = cx_Oracle.connect("your_username", "your_psw", "localhost/orcl")
      
      cursor = connection.cursor()
      
      cursor.execute("""select to_char(sysdate, 'dd-mon-yyyy') from dual""")
      
      for cdate in cursor:
      
          print("Today the date is ", cdate)
      

    Output:

     Today the date is  ('08-nov-2019',)
    

提交回复
热议问题