Installing Python cx_Oracle module on Ubuntu 10.04

來源:互聯網
上載者:User
Installing Python cx_Oracle module on Ubuntu 10.04Step 1: Install Prerequisite Software


You will need to have the following packages installed to get Oracle Instant Client and cx_Oracle installed:

* build-essential
* unzip
* python-dev
* libaio-dev

so go in a terminal and type:


sudo apt-get install build-essential unzip python-dev libaio-dev




Step 2: Download and unzip Oracle's instantclient archives


These hints are based on using Oracle'sinstantclient_11_1
It is necessary to download both instantclient-linux-basic and instantclient-sdk-linux fromoracle.com in
order to successfully compile.

Each compressed tarball needs to be extracted to the exact same location.
Uncompress and untar each file from the same location in order to achieve this
result.

After both packages are untarred to there installation location a link needs
to be made inside the instantclient_11_1 directory


cd $ORACLE_HOME
ln -s libclntsh.so.x.x libclntsh.so




Step 3: Set environment variables


It is necessary to set environment variablesORACLE_HOME and LD_LIBRARY_PATH inside $HOME/.profilein
order for cx_Oracle to import properly after installation and in order to build correctly.

Example (/etc/profile):


export ORACLE_HOME=[your installation path]/instantclient_11_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME


Hint:

If after modifying your /etc/.profile the system cannot found  $ORACLE_HOME add this variables in /etc/environment then
log off and log in again to force the environment reload.




Step 4: Update ldconfig


Add the instantclient path ([your installation path]/instantclient_11_1) to ldconfig:

sudo gedit /etc/ld.so.conf.d/oracle.conf


then iussue an

ldconfig




Step 5: Download and build cx_Oracle


Download cx_Oracle at http://cx-oracle.sourceforge.net and unzip wherever you want, then...


cd [your cx_Oracle installation path]
python setup.py build
python setup.py install


Make a quick check:


luca@ubuntu:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> print cx_Oracle.version
5.0.3





In case of troubles


If you get this message during the quick check step:


luca@ubuntu:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "", line 1, in 
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory


You forgot to add the instantclient path in ldconfig; adding it will fix this problem.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.