install cx_oracle for python

后端 未结 11 1755
逝去的感伤
逝去的感伤 2021-01-30 04:27

Am on Debian 5, I\'ve been trying to install cx_oracle module for python without any success. First, I installed oracle-xe-client and its dependency (followed tutorial in the fo

11条回答
  •  日久生厌
    2021-01-30 05:03

    The alternate way, that doesn't require RPMs. You need to be root.

    1. Dependencies

      Install the following packages:

      apt-get install python-dev build-essential libaio1
      
    2. Download Instant Client for Linux x86-64

      Download the following files from Oracle's download site:

    3. Extract the zip files

      Unzip the downloaded zip files to some directory, I'm using:

      /opt/ora/
      
    4. Add environment variables

      Create a file in /etc/profile.d/oracle.sh that includes

      export ORACLE_HOME=/opt/ora/instantclient_11_2
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
      

      Create a file in /etc/ld.so.conf.d/oracle.conf that includes

      /opt/ora/instantclient_11_2
      

      Execute the following command

      sudo ldconfig
      

      Note: you may need to reboot to apply settings

    5. Create a symlink

      cd $ORACLE_HOME 
      ln -s libclntsh.so.11.1 libclntsh.so
      
    6. Install cx_Oracle python package

      • You may install using pip

        pip install cx_Oracle
        
      • Or install manually

        Download the cx_Oracle source zip that corresponds with your Python and Oracle version. Then expand the archive, and run from the extracted directory:

        python setup.py build 
        python setup.py install
        

提交回复
热议问题